Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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','twilight','deepdark']
- }
- };
- 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'
- });
- var mapTypeTwilight = new google.maps.ImageMapType({
- getTileUrl: function(coord, zoom) {
- var z = 5 - zoom;
- return 'images/DIM7/z' + z + '/' + coord.x + '.' + coord.y + '.png';
- },
- tileSize: new google.maps.Size(512, 512),
- maxZoom: 6,
- minZoom: 0,
- name: 'Twilight'
- });
- var mapTypeDeepDark = new google.maps.ImageMapType({
- getTileUrl: function(coord, zoom) {
- var z = 5 - zoom;
- return 'images/DIM-100/z' + z + '/' + coord.x + '.' + coord.y + '.png';
- },
- tileSize: new google.maps.Size(512, 512),
- maxZoom: 6,
- minZoom: 0,
- name: 'Deep Dark'
- });
- // use the custom latitude and logitude projection
- mapTypeOverworld.projection = new ProjectionCartesian();
- mapTypeNether.projection = new ProjectionCartesian();
- mapTypeTwilight.projection = new ProjectionCartesian();
- mapTypeDeepDark.projection = new ProjectionCartesian();
- // add the map type to the map
- map.mapTypes.set('overworld', mapTypeOverworld);
- map.mapTypes.set('nether', mapTypeNether);
- map.mapTypes.set('twilight', mapTypeTwilight);
- map.mapTypes.set('deepdark', mapTypeDeepDark);
- 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()">
- <div id="map_canvas" style="width: 100%; height: 100%;"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement