Posted By

rccc on 01/18/10


Tagged

gmap


Versions (?)

GTileOverlay


 / Published in: JavaScript
 

  1. if (GBrowserIsCompatible()) {
  2.  
  3. // // Set up the copyright information
  4. // // Each image used should indicate its copyright permissions
  5. // var myCopyright = new GCopyrightCollection("(c) ");
  6. // myCopyright.addCopyright(new GCopyright('Demo',
  7. // new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)),
  8. // 0,'©2007 Google'));
  9. //
  10. // // Create the tile layer overlay and
  11. // // implement the three abstract methods
  12. // var tilelayer = new GTileLayer(myCopyright);
  13. // tilelayer.getTileUrl = function() { return "http://fundrace.huffingtonpost.com/gmaps/tiles/white.png"; };
  14. // tilelayer.isPng = function() { return true;};
  15. // tilelayer.getOpacity = function() { return 0.5; }
  16. //
  17. // var myTileLayer = new GTileLayerOverlay(tilelayer);
  18.  
  19. map = new GMap2(document.getElementById("map_canvas"));
  20. map.addControl(new GSmallMapControl());
  21. map.setCenter(new GLatLng(47,2, 1.2), 8);
  22. // map.setMapType(map.getMapTypes()[0]);
  23.  
  24. // map.setCenter(new GLatLng(47,2, 1.2), 8);
  25. // map.addOverlay(myTileLayer);
  26. addHybridLayers(map, ['http://fundrace.huffingtonpost.com/gmaps/tiles/white.png'], new GLatLng(47,2, 1.2), 8);
  27.  
  28. }
  29. }
  30.  
  31. function addHybridLayers(aMap, tile_urls, labels, centerPoint, zoom)
  32. {
  33. var tilelayers = [];
  34. var hybridLayer = [];
  35.  
  36. CustomMapTypes = [];
  37.  
  38. for (var mapIndex = 0; mapIndex < tile_urls.length; mapIndex++)
  39. {
  40. tilelayers[mapIndex] = new GTileLayer(new GCopyrightCollection("Huffington Post"),5,15);
  41. tilelayers[mapIndex].getCopyright = function(a,b) { return {prefix:"Imagery: &#169; 2007", copyrightTexts:["Huffington Post"]}; }
  42. tilelayers[mapIndex].getTileUrl = tile_urls[mapIndex];
  43.  
  44. hybridLayer[mapIndex] = [
  45. tilelayers[mapIndex], // a reference to the tile layer from the first custom map
  46. G_HYBRID_MAP.getTileLayers()[1] // a reference to the upper tile layer of the hybrid map
  47. ];
  48. CustomMapTypes[mapIndex] = new GMapType(hybridLayer[mapIndex], G_SATELLITE_MAP.getProjection(), labels[mapIndex]);
  49. CustomMapTypes[mapIndex].getMinimumResolution = function() {return 3;};
  50.  
  51. CustomMapTypes[mapIndex].getMaximumResolution = function() {return 16;};
  52.  
  53. aMap.addMapType(CustomMapTypes[mapIndex]);
  54. }
  55.  
  56. aMap.removeMapType(G_SATELLITE_MAP);
  57. aMap.removeMapType(G_HYBRID_MAP);
  58. aMap.removeMapType(G_NORMAL_MAP);
  59.  
  60. }

Report this snippet  

You need to login to post a comment.