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: "medium", 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.enableScrollWheelZoom(); bounds = new GLatLngBounds; map.setCenter(new GLatLng(48.48885175366314,-1.9994258880615234), 14); var marker14 = new GIcon(); marker14.image = "http://chambretypic.free.fr/components/com_svmap/markers/letter-a.png"; marker14.iconSize = new GSize(20,34); marker14.iconAnchor = new GPoint(10,34); marker14.infoWindowAnchor = new GPoint(10,17); businesses = [[1,marker14,"",48.48898187942329,-1.999361515045166,'




',"/index.php?option=com_svmap&layout=business&business=1&name=&Itemid=10",""]]; addBusinesses(); } } 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 = '
Trouver un itinéraire : A partir de ce lieu - Vers ce lieu
'; 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 = "Aucune localisation géographic n'a pu être trouvé pour cette adresse. Cela peut venir du fait que l'adresse est trop récente, ou incorrecte."; break; case 603: message = "L'itinéraire demandé ne peut être communiqué pour des raisons légales ou contractuelles."; break; case 604: message = "L'itinéraire demandé n'a pas pu être trouvé. Cela peut venir du fait qu'aucun itinéraire n'existe entre ces deux points, ou parcequ'il n'y a pas d'informations de localisation dans cette région."; break; default: message = "L'itinéraire demandé n'a pas pu être trouvé."; break; } alert(message); }