var map; var bounds; var businesses; var geocodes; var cntGeocoded = 0; var directionsPanel; var directions; var focusedBusiness; function generateMap() { if (GBrowserIsCompatible() && document.getElementById("svmap_canvas") != null) { geocoder = new GClientGeocoder(); geocoder.setCache(null); var mapOptions = { mapTypes:[G_NORMAL_MAP] , googleBarOptions : { style : "new", adsOptions: { client: "ca-pub-2835077168755201", channel: "", adsafe: "high", language: "en" } } }; map = new GMap2(document.getElementById("svmap_canvas"), mapOptions); var mapControl = new GMapTypeControl(); map.addControl(mapControl); map.addControl(new GLargeMapControl()); map.enableGoogleBar(); map.addControl(new GOverviewMapControl()); map.disableDoubleClickZoom(); map.disableScrollWheelZoom(); bounds = new GLatLngBounds; map.setCenter(new GLatLng(43.30269535028555,13.725357055664062), 11); var marker1 = new GIcon(); marker1.image = "http://www.icare-onlus.com/components/com_svmap/markers/blue.png"; marker1.iconSize = new GSize(12,20); marker1.iconAnchor = new GPoint(6,20); marker1.infoWindowAnchor = new GPoint(6,10); businesses = [[62,marker1,"",43.29220075008278,13.723297119140625,'




',"/users-map/business/62.html",""]]; addBusinesses(); geocodes = [[66,marker1,"",,,'




',"/users-map/business/66.html",""],[67,marker1,"",,,'




',"/users-map/business/67.html",""]]; geocodeBusinesses(); } } function setBounds(bounds) { map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); } function geocodeBusinesses() { if (cntGeocoded < geocodes.length) { geocoder.getLocations(geocodes[cntGeocoded][7], addressResolved); } } function addressResolved(response) { var delay = 0; if (response.Status.code == 620) { delay = 500; } else { if (response.Status.code == 200) { var address = response.Placemark[0]; geocodes[cntGeocoded][3] = address.Point.coordinates[1]; geocodes[cntGeocoded][4] = address.Point.coordinates[0]; addBusiness(geocodes[cntGeocoded]); } // Move onto the next address; this skips bad addresses, too. cntGeocoded += 1; } window.setTimeout(geocodeBusinesses, delay); } function addBusinesses() { for (var i=0; i < businesses.length; i++) { addBusiness(businesses[i]); } } function addBusiness(business) { var point = new GLatLng(business[3], business[4]); var markerOptions = { icon:business[1], draggable: false, "title":business[2] }; var marker = new GMarker(point, markerOptions); var form = '
Get directions : From here - To here
'; var info = business[5]; info += form; var div = document.createElement("div"); div.style.width = "200px"; div.style.height = "200px"; var pano = new GStreetviewPanorama(div); pano.setLocationAndPOV(point); GEvent.addListener(pano, "error", function() { marker.bindInfoWindowHtml(info); } ); var tabs = [new GInfoWindowTab('Info', info),new GInfoWindowTab('StreetView', div)]; marker.bindInfoWindowTabsHtml(tabs); GEvent.addListener(marker, "infowindowopen", function() { pano.show(); }); GEvent.addListener(marker, "infowindowbeforeclose", function() { pano.hide(); }); map.addOverlay(marker); } function showFormFrom() { document.getElementById('formFrom').style.display = 'block'; document.getElementById('formTo').style.display = 'none'; return false; } function showFormTo() { document.getElementById('formTo').style.display = 'block'; document.getElementById('formFrom').style.display = 'none'; return false; } function findDirections(from, to) { if (directions == null) { directionsPanel = document.getElementById('svmap_directions_panel'); directions = new GDirections(map, directionsPanel); GEvent.addListener(directions, "error", directionsError); } else { directions.clear(); } directions.load("from: "+from+" to: "+to); } function directionsError(response) { status = response.getStatus(); switch (status.code) { case 602: message = "No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect."; break; case 603: message = "The route for the given directions query cannot be returned due to legal or contractual reasons."; break; case 604: message = "The directions between the points mentioned in the query could not be computed. This is usually because there is no route available between the two points, or because there is no data for routing in that region."; break; default: message = "The directions between the points mentioned in the query could not be computed."; break; } alert(message); }