Skip to content

Commit f7b7bad

Browse files
committed
feat: added map type for postcode map
As soon as davwheat sends me the map, I will upload the images. This update just gets the interface for said images.
1 parent 69a9d96 commit f7b7bad

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

index.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@
7171

7272
<script src="js/jquery-3.2.1.min.js"></script>
7373
<script src="js/bootstrap.min.js"></script>
74-
75-
<!-- Change the key below -->
7674
<script type="text/javascript" src="https://maps.google.com/maps/api/js"></script>
77-
75+
7876
<script>
7977

8078
///////////////////////////////////////////////////////////////////////////
@@ -83,18 +81,21 @@
8381
var _MAP_tileURL = "<?php echo $config->mapTileUrl; ?>";
8482
var _MAP_iconURL = "<?php echo $config->mapIconUrl; ?>";
8583

86-
// Set if to show Atlas map (WARNING: REQUIRES "atlas" TILE DIRECTORY)
84+
// Sets whether it should showSets whether it should show Atlas map (WARNING: REQUIRES "atlas" TILE DIRECTORY)
8785
var _MAP_atlasMap = <?php echo json_encode($config->atlasEnabled); ?>;
8886

89-
// Set if to show Satellite map (WARNING: REQUIRES "satellite" TILE DIRECTORY)
87+
// Sets whether it should show Satellite map (WARNING: REQUIRES "satellite" TILE DIRECTORY)
9088
var _MAP_satelliteMap = <?php echo json_encode($config->satelliteEnabled); ?>;
9189

92-
// Set if to show Road map (WARNING: REQUIRES "road" TILE DIRECTORY)
90+
// Sets whether it should show Road map (WARNING: REQUIRES "road" TILE DIRECTORY)
9391
var _MAP_roadMap = <?php echo json_encode($config->roadEnabled); ?>;
9492

95-
// Set if to show UV Invert map (WARNING: REQUIRES "uv-invert" TILE DIRECTORY)
93+
// Sets whether it should show UV Invert map (WARNING: REQUIRES "uv-invert" TILE DIRECTORY)
9694
var _MAP_UVInvMap = <?php echo json_encode($config->uvInveredEnabled); ?>;
9795

96+
// Sets whether it should show Postcode map (WARNING: REQUIRES "postcode" TILE DIRECTORY)
97+
var _MAP_PostcodeMap = <?php echo json_encode($config->postcodeEnabled); ?>;
98+
9899
// Set to the IP of the GTA server running "live_map" and change the port to the
99100
// number that is set
100101
var _SETTINGS_socketUrl = "<?php echo $config->socketUrl(); ?>";

js/src/map.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function getNormalizedCoord(coord, zoom) {
5050
};
5151
}
5252

53-
53+
// Start atlas
5454
var mapAtlasOptions = {
5555
getTileUrl: function(coord, zoom) {
5656
var normalizedCoord = getNormalizedCoord(coord, zoom);
@@ -66,6 +66,9 @@ var mapAtlasOptions = {
6666
};
6767
var mapAtlas = new google.maps.ImageMapType(mapAtlasOptions);
6868
mapAtlas.projection = new EuclideanProjection();
69+
//End atlas
70+
71+
//Start satellite
6972
var mapSatelliteOptions = {
7073
getTileUrl: function(coord, zoom) {
7174
var normalizedCoord = getNormalizedCoord(coord, zoom);
@@ -81,6 +84,9 @@ var mapSatelliteOptions = {
8184
};
8285
var mapSatellite = new google.maps.ImageMapType(mapSatelliteOptions);
8386
mapSatellite.projection = new EuclideanProjection();
87+
//end satellite
88+
89+
//start road
8490
var mapRoadOptions = {
8591
getTileUrl: function(coord, zoom) {
8692
var normalizedCoord = getNormalizedCoord(coord, zoom);
@@ -96,6 +102,9 @@ var mapRoadOptions = {
96102
};
97103
var mapRoad = new google.maps.ImageMapType(mapRoadOptions);
98104
mapRoad.projection = new EuclideanProjection();
105+
//end road
106+
107+
//start UV
99108
var mapUVInvOptions = {
100109
getTileUrl: function(coord, zoom) {
101110
var normalizedCoord = getNormalizedCoord(coord, zoom);
@@ -111,6 +120,25 @@ var mapUVInvOptions = {
111120
};
112121
var mapUVInv = new google.maps.ImageMapType(mapUVInvOptions);
113122
mapUVInv.projection = new EuclideanProjection();
123+
//end uv
124+
125+
// Postcode map
126+
var mapPostcodeOptions = {
127+
getTileUrl: function(coord, zoom) {
128+
var normalizedCoord = getNormalizedCoord(coord, zoom);
129+
if (!normalizedCoord || normalizedCoord.x > bounds[zoom] || normalizedCoord.y > bounds[zoom]) {
130+
return null;
131+
}
132+
return _MAP_tileURL + 'postcode/' + zoom + '_' + normalizedCoord.x + '_' + normalizedCoord.y + '.png';
133+
},
134+
tileSize: new google.maps.Size(256, 256),
135+
maxZoom: 7,
136+
name: "Postcode",
137+
alt: "GTA V Postcode Map"
138+
};
139+
var mapPostcode = new google.maps.ImageMapType(mapPostcodeOptions);
140+
mapPostcode.projection = new EuclideanProjection();
141+
//end postcode
114142

115143
function mapInit(elementID) {
116144
_MAP_markerStore = [];
@@ -120,6 +148,7 @@ function mapInit(elementID) {
120148
_MAP_satelliteMap ? mapID.push("Satellite") : null;
121149
_MAP_roadMap ? mapID.push("Road") : null;
122150
_MAP_UVInvMap ? mapID.push("UV Invert") : null;
151+
_MAP_PostcodeMap ? mapID.push("Postcode") : null;
123152
var mapOptions = {
124153
backgroundColor: "#0fa8d2",
125154
minZoom: 3,
@@ -138,6 +167,7 @@ function mapInit(elementID) {
138167
_MAP_satelliteMap ? map.mapTypes.set("Satellite", mapSatellite) : null;
139168
_MAP_roadMap ? map.mapTypes.set("Road", mapRoad) : null;
140169
_MAP_UVInvMap ? map.mapTypes.set("UV Invert", mapUVInv) : null;
170+
_MAP_PostcodeMap ? map.mapTypes.set("Postcode", mapPostcode) : null;
141171
map.setMapTypeId("Atlas");
142172
google.maps.event.addListener(map, "maptypeid_changed", function() {
143173
var type = map.getMapTypeId();
@@ -162,6 +192,11 @@ function mapInit(elementID) {
162192
"background-color": "#f2f0b6"
163193
});
164194
break
195+
default:
196+
$("#" + elementID).css({
197+
"background-color": "#0fa8d2"
198+
});
199+
break;
165200
}
166201
});
167202
}

utils/config.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class Config{
6666
// Controls whether the uv-invert map is enabled or not
6767
// (WARNING: REQUIRES "uv-invert" TILE DIRECTORY INSIDE "mapTileUrl"
6868
public $uvInveredEnabled = true;
69+
// Controls whether the post-code map is enabled or not
70+
// (WARNING: REQUIRES "postcode" TILE DIRECTORY INSIDE "mapTileUrl"
71+
public $postcodeEnabled = false;
6972

7073
// Do you want to show the player's identifiers on the map?
7174
// Note: THIS MAY BE THE PLAYER'S IP ADDRESS
@@ -99,7 +102,7 @@ public function blipUrl(){
99102
}
100103

101104
private static $instance = NULL;
102-
105+
103106
public static function getConfig(){
104107
if (is_null(self::$instance)){
105108
self::$instance = new self();

0 commit comments

Comments
 (0)