Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 2.16 KB  |  hits: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //load Google Map
  2.  
  3.  
  4. var directions;
  5. var map;
  6.        
  7. function loadGMap() {
  8.   if (GBrowserIsCompatible()) {
  9.  
  10.         map = new GMap2(document.getElementById("GoogleMap") );//,{ size: new GSize(435, 470) }
  11.     var directionsPanel = document.getElementById("GoogleMapDirections");
  12.         directions = new GDirections(map, directionsPanel);
  13.        
  14.     GEvent.addListener(directions, "load", onGDirectionsLoad);
  15.     GEvent.addListener(directions, "error", handleErrors);
  16.        
  17.     var geocoder = new GClientGeocoder();
  18.         map.addControl(new GLargeMapControl3D());
  19.  
  20.     map.addControl(new GMapTypeControl());
  21.     map.enableScrollWheelZoom();
  22.  
  23.     showAddress(map,directions,geocoder,gAddress,gCity,gImage);
  24.  
  25.   } //close GBrowserIsCompatible
  26. } //close load
  27.  
  28.  
  29. //Create marker and set up event window
  30. function createMarker(point,html,icon){
  31.   var marker = new GMarker(point,icon);
  32.           marker.openInfoWindowHtml(html);
  33.  
  34.   return marker;
  35. }
  36.  
  37. //showAddress
  38. function showAddress(map,directions,geocoder,address,city,image) {
  39.        
  40.   geocoder.getLatLng(
  41.     address,
  42.     function(point) {
  43.       if (!point) {
  44.         //alert(address + " niet gevonden");
  45.       } else {      
  46.                 map.setCenter(point, 11);
  47.                 var marker = createMarker(point,
  48.                                 '<h3 class="ballon">'+city+'</h3><p>'+address+'</p><div align="center"><img alt="'+address+', '+city+'" src="'+image+'" /></div>'
  49.                         );
  50.        
  51.             directions.load("from: 500 Memorial Drive, Cambridge, MA to: "+address);
  52.                 map.addOverlay(marker);        
  53.                
  54.       }
  55.     }
  56.   );
  57. }
  58.  
  59. function setDirections(fromAddress, toAddress) {
  60.         directions.load("from: " + fromAddress + " to: " + toAddress,
  61.         { "locale": "nl_NL" });
  62. }
  63.  
  64. function handleErrors(){
  65.  
  66. }
  67.  
  68. function onGDirectionsLoad(){
  69.   // Use this function to access information about the latest load()
  70.   // results.
  71.  
  72.   // e.g.
  73.   // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
  74.   // and yada yada yada...
  75. }
  76. //load Google Map
  77. $(function(){
  78. if (typeof loadGMap == "function") {
  79.         loadGMap();
  80. }
  81. });
  82. //unload Google Map
  83. jQuery(window).bind("unload", function() {
  84.     if (typeof GUnload == "function") {
  85.         GUnload();
  86.     }
  87. });