forked from daveyliam/anvilmapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
153 lines (127 loc) · 3.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<html>
<head>
<title>Minecraft World Map</title>
<!--
You can set your own Google Maps API Key here:
e.g. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSxRT67cflfOI5g23bfGeQUcT6xY7Q3WbWA&sensor=false"></script>
-->
<script src="https://maps.googleapis.com/maps/api/js?&sensor=false"></script>
<script>
var markerArray = [];
var map = null;
var markerVisibility = true;
// functions to add, hide, and delete markers
function addMarker(x, y, icon, title) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(y / 512, x / 512),
map: map,
icon: icon,
title: title + " (" + x + ", " + y + ")"
});
markerArray.push(marker);
}
function toggleAllMarkers() {
markerVisibility = !markerVisibility;
for (i in markerArray) {
markerArray[i].setVisible(markerVisibility);
}
}
function deleteAllMarkers() {
for (i in markerArray) {
markerArray[i].setMap(null);
}
markerArray.length = 0;
}
// custom projection
// lat range is [-4,4] corresponding to y [-512,512] in the zoom level 0 image set
// lng range is [-4,4] corresponding to x [-512,512] in the zoom level 0 image set
// in terms of game coordinates:
// inGameX = lng * 1024
// inGameZ = lat * 1024
function ProjectionCartesian() {};
ProjectionCartesian.prototype.fromLatLngToPoint = function(latLng) {
return new google.maps.Point(latLng.lng() * 512 / 32, latLng.lat() * 512 / 32);
};
ProjectionCartesian.prototype.fromPointToLatLng = function(point, noWrap) {
return new google.maps.LatLng(point.y / 512 * 32, point.x / 512 * 32, noWrap);
};
// icon definitions for markers
var iconSpawn = {
path: google.maps.SymbolPath.CIRCLE,
fillColor: "red",
fillOpacity: 1.0,
scale: 4,
strokeColor: "black",
strokeWeight: 1
};
var iconPortal = {
path: 'M -1,-1 1,-1 1,1 -1,1 z',
fillColor: "purple",
fillOpacity: 1.0,
scale: 4,
strokeColor: "black",
strokeWeight: 1
};
// the initialization function, called when the page body loads
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(0, 0),
zoom: 2,
streetViewControl: false,
zoomControl: true,
panControl: false,
scaleControl: false,
mapTypeControlOptions: {
mapTypeIds: ['overworld', 'nether']
}
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
// can define multiple mapTypes (similar to how standard google maps has satellite, map, hybrid).
var mapTypeOverworld = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
var z = 5 - zoom;
return 'images/z' + z + '/' + coord.x + '.' + coord.y + '.png';
},
tileSize: new google.maps.Size(512, 512),
maxZoom: 6,
minZoom: 0,
name: 'Overworld'
});
var mapTypeNether = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
var z = 5 - zoom;
return 'images/DIM-1/z' + z + '/' + coord.x + '.' + coord.y + '.png';
},
tileSize: new google.maps.Size(512, 512),
maxZoom: 6,
minZoom: 0,
name: 'Nether'
});
// use the custom latitude and logitude projection
mapTypeOverworld.projection = new ProjectionCartesian();
mapTypeNether.projection = new ProjectionCartesian();
// add the map type to the map
map.mapTypes.set('overworld', mapTypeOverworld);
map.mapTypes.set('nether', mapTypeNether);
map.setMapTypeId('overworld');
// listener for clicks on the map surface
google.maps.event.addListener(map, 'rightclick', function(event) {
toggleAllMarkers();
});
// add markers
//addMarker(0, 0, iconSpawn, "origin");
//addMarker(-512, 512, iconSpawn, "");
//addMarker(512, -512, iconSpawn, "");
//addMarker(-506, -262, iconPortal, "end portal");
//addMarker(948, -288, iconPortal, "end portal");
//addMarker(-71, 846, iconPortal, "end portal");
}
</script>
</head>
<body onload="initialize()">
<h4>Minecraft World Map</h4>
<div id="map_canvas" style="width: 800px; height: 600px;"></div>
Right click map to show/hide markers.<br />
Markers can be created by editing 'index.html'.<br />
</body>
</html>