Advertisement
smbarbour

AnvilMapper html with extra dimensions

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