- //load Google Map
- var directions;
- var map;
- function loadGMap() {
- if (GBrowserIsCompatible()) {
- map = new GMap2(document.getElementById("GoogleMap") );//,{ size: new GSize(435, 470) }
- var directionsPanel = document.getElementById("GoogleMapDirections");
- directions = new GDirections(map, directionsPanel);
- GEvent.addListener(directions, "load", onGDirectionsLoad);
- GEvent.addListener(directions, "error", handleErrors);
- var geocoder = new GClientGeocoder();
- map.addControl(new GLargeMapControl3D());
- map.addControl(new GMapTypeControl());
- map.enableScrollWheelZoom();
- showAddress(map,directions,geocoder,gAddress,gCity,gImage);
- } //close GBrowserIsCompatible
- } //close load
- //Create marker and set up event window
- function createMarker(point,html,icon){
- var marker = new GMarker(point,icon);
- marker.openInfoWindowHtml(html);
- return marker;
- }
- //showAddress
- function showAddress(map,directions,geocoder,address,city,image) {
- geocoder.getLatLng(
- address,
- function(point) {
- if (!point) {
- //alert(address + " niet gevonden");
- } else {
- map.setCenter(point, 11);
- var marker = createMarker(point,
- '<h3 class="ballon">'+city+'</h3><p>'+address+'</p><div align="center"><img alt="'+address+', '+city+'" src="'+image+'" /></div>'
- );
- directions.load("from: 500 Memorial Drive, Cambridge, MA to: "+address);
- map.addOverlay(marker);
- }
- }
- );
- }
- function setDirections(fromAddress, toAddress) {
- directions.load("from: " + fromAddress + " to: " + toAddress,
- { "locale": "nl_NL" });
- }
- function handleErrors(){
- }
- function onGDirectionsLoad(){
- // Use this function to access information about the latest load()
- // results.
- // e.g.
- // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
- // and yada yada yada...
- }
- //load Google Map
- $(function(){
- if (typeof loadGMap == "function") {
- loadGMap();
- }
- });
- //unload Google Map
- jQuery(window).bind("unload", function() {
- if (typeof GUnload == "function") {
- GUnload();
- }
- });