Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Commit cfdedc9

Browse files
committed
feat: add overlays
Overlays, Overlays, Overlays! So, the map images now have a street overlay folder that is, well, overlayed onto the over images. Woo. So, now you don't need to send the street names with the player data.. Well, if you still want that you can. Just make sure to download the latest image release, and pop them into your map folder.
1 parent ea37d41 commit cfdedc9

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

index.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@
249249
<span id="blips_enabled" class="badge badge-pill badge-success pull-right">on</span>
250250
</a>
251251

252+
<a class="list-group-item d-inline-block collapsed">
253+
<span class="d-md-inline">Map overlay</span>
254+
255+
<select id="overlaySelect" class="input-large form-control pull-right">
256+
<option value="-1">None</option>
257+
</select>
258+
</a>
259+
252260
<!--
253261
<li>
254262
<a id="toggleLive" href="#">Live update <span id="live_enabled" class="badge badge-danger pull-right">off</span></a>
@@ -300,7 +308,7 @@
300308
<a class="nav-header">Blip Controls</a>
301309

302310
<div id="blip-control-container" class="row">
303-
311+
304312
</div>
305313

306314
</div>

js/src/controls.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ $(document).ready(function(){
4040
globalInit();
4141
connect();
4242

43+
44+
$("#overlaySelect").on("change", function(){
45+
if(this.value == -1){
46+
map.overlayMapTypes.setAt(0,null);
47+
}else{
48+
if(_overlays[this.value] != undefined){
49+
map.overlayMapTypes.setAt(0, _overlays[this.value]);
50+
}
51+
}
52+
});
53+
4354
$("#playerSelect").on("change", function(){
4455
if (this.value == ""){
4556
_trackPlayer = null;

js/src/init.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@ var _showBlips = true;
2424
var _isConnected = false;
2525
var _trackPlayer = null;
2626
var playerCount = 0;
27+
var _overlays = [];
2728

2829
function globalInit() {
2930
mapInit("map-canvas");
3031
initPage();
3132
initBlips();
33+
34+
for (var i = 0; i < _overlays.length; i++) {
35+
var o = _overlays[i];
36+
$("#overlaySelect").append(`<option value="${i}">${o.name}</option>`);
37+
}
38+
3239
}
3340

3441
function initPage() {

js/src/map.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,26 @@ function getNormalizedCoord(coord, zoom) {
5050
};
5151
}
5252

53+
var streetOverlayImages = new google.maps.ImageMapType({
54+
getTileUrl: function(coord, zoom) {
55+
var normalizedCoord = getNormalizedCoord(coord, zoom);
56+
if (!normalizedCoord) {
57+
return null;
58+
}
59+
return _MAP_tileURL + 'overlay_streets/' + zoom + '-' + coord.x + '_' + coord.y + '.png';
60+
},
61+
tileSize: new google.maps.Size(256, 256),
62+
name: "Street names"
63+
});
64+
5365
// Start atlas
5466
var mapAtlasOptions = {
5567
getTileUrl: function(coord, zoom) {
5668
var normalizedCoord = getNormalizedCoord(coord, zoom);
5769
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
5870
return null;
5971
}
60-
return _MAP_tileURL + 'atlas/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
72+
return _MAP_tileURL + 'atlas/' + zoom + '-' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
6173
},
6274
tileSize: new google.maps.Size(256, 256),
6375
maxZoom: 7,
@@ -75,7 +87,7 @@ var mapSatelliteOptions = {
7587
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
7688
return null;
7789
}
78-
return _MAP_tileURL + 'satellite/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
90+
return _MAP_tileURL + 'satellite/' + zoom + '-' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
7991
},
8092
tileSize: new google.maps.Size(256, 256),
8193
maxZoom: 7,
@@ -93,11 +105,11 @@ var mapRoadOptions = {
93105
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
94106
return null;
95107
}
96-
return _MAP_tileURL + 'road/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
108+
return _MAP_tileURL + 'road/' + zoom + '-' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
97109
},
98110
tileSize: new google.maps.Size(256, 256),
99111
maxZoom: 7,
100-
minZoom: 5,
112+
//minZoom: 5,
101113
name: "Road",
102114
alt: "GTA V Road Map"
103115
};
@@ -112,7 +124,7 @@ var mapUVInvOptions = {
112124
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
113125
return null;
114126
}
115-
return _MAP_tileURL + 'uv-invert/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
127+
return _MAP_tileURL + 'uv-invert/' + zoom + '-' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
116128
},
117129
tileSize: new google.maps.Size(256, 256),
118130
maxZoom: 7,
@@ -130,7 +142,7 @@ var mapPostcodeOptions = {
130142
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
131143
return null;
132144
}
133-
return _MAP_tileURL + 'postcode/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
145+
return _MAP_tileURL + 'postcode/' + zoom + '-' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
134146
},
135147
tileSize: new google.maps.Size(256, 256),
136148
maxZoom: 7,
@@ -169,6 +181,12 @@ function mapInit(elementID) {
169181
_MAP_roadMap ? map.mapTypes.set("Road", mapRoad) : null;
170182
_MAP_UVInvMap ? map.mapTypes.set("UV Invert", mapUVInv) : null;
171183
_MAP_PostcodeMap ? map.mapTypes.set("Postcode", mapPostcode) : null;
184+
185+
//TODO: Maybe make this an option or something?
186+
_overlays.push(streetOverlayImages);
187+
188+
//TODO: If a postcode overlay get made or something, add it here too..
189+
172190
map.setMapTypeId("Atlas");
173191
google.maps.event.addListener(map, "maptypeid_changed", function() {
174192
var type = map.getMapTypeId();

0 commit comments

Comments
 (0)