Posted By

rccc on 01/18/10


Tagged

gmap


Versions (?)

custom map


 / Published in: JavaScript
 

  1. if (GBrowserIsCompatible()) {
  2.  
  3. var min = 0;
  4. var max = 12;
  5.  
  6. //copyright
  7. var license = "<a href='http://www.maps-for-free.com/html/about.html' target='_blank'>License</a>";
  8. var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, license);
  9. var copyrightCollection = new GCopyrightCollection("Relief Maps: ");
  10. copyrightCollection.addCopyright(copyright);
  11.  
  12. // Relief Map
  13. var relief = [new GTileLayer(copyrightCollection, min, max)];
  14. relief[0].getTileUrl = function(a,b) {
  15. return "http://maps-for-free.com/layer/relief/z" + b + "/row" + a.y + "/" + b + "_" + a.x + "-" + a.y + ".jpg"; };
  16. reliefLayer = new GMapType(relief, G_SATELLITE_MAP.getProjection(), "Relief", {minResolution:min, maxResolution:max});
  17.  
  18. // Water Layer
  19. function getWaterLayer() {
  20. var layer = new GTileLayer(copyrightCollection, min, max);
  21. layer.getTileUrl = function (a,b) {
  22. return "http://maps-for-free.com/layer/water/z" + b + "/row" + a.y + "/" + b + "_" + a.x + "-" + a.y + ".gif"; };
  23. return layer;
  24. }
  25.  
  26. var map = new GMap2(document.getElementById("map"));
  27. map.setCenter(new GLatLng(37, 0), 4);
  28.  
  29. // Add Water Layer
  30. waterLayer = new GTileLayerOverlay(getWaterLayer());
  31. map.addOverlay(waterLayer);
  32. waterLayer.visible = true;
  33.  
  34. // Add Label Layer
  35. // labelLayer = new GTileLayerOverlay(G_HYBRID_MAP.getTileLayers()[1]);
  36. // map.addOverlay(labelLayer);
  37. // labelLayer.visible = true;
  38.  
  39. map.addMapType(reliefLayer);
  40. map.addControl(new GLargeMapControl());
  41. map.addControl(new GOverviewMapControl());
  42. map.addControl(new GScaleControl());
  43.  
  44. map.setMapType(reliefLayer);
  45.  
  46. map.enableDoubleClickZoom();
  47. map.enableContinuousZoom();
  48. map.enableScrollWheelZoom();
  49.  
  50.  
  51.  
  52. }
  53.  
  54.  
  55. // display a warning if the browser was not compatible
  56. else {
  57. alert("Sorry, the Google Maps API is not compatible with this browser");
  58. }

Report this snippet  

You need to login to post a comment.