/* * Javascript Mode unobstructive * * Gestion des maps google */ var mapeed, mapeedMap, map, polyline1_1, geocoder, address, GDir1, GDir2, normalProj, waypoints=[], gpolys=[], routeNodes=[], myNode, markerDragged, isDragged, lastIndex, prevIndex, searchAreaHighlight_destination, searchAreaHighlight_depart, radiusA = 5, radiusB = 5; geocoder = null; map = null; function loadGmap() { if(document.getElementById("carte")){ map = new GMap2(document.getElementById("carte"), {draggableCursor:"crosshair"}); map.setCenter(new GLatLng('44.172355652','0.450237006'), 9); mgr = new MarkerManager(map); geocoder = new GClientGeocoder(); var sw = new GLatLng(43.97282059, -0.14067308); var ne = new GLatLng(44.76420594, 1.07777218); var bounds = new GLatLngBounds(sw, ne); var mapZoomLevel = map.getBoundsZoomLevel(bounds); var mapCenter = new GLatLng(44.368513265, 0.46854955) map.setCenter(mapCenter, mapZoomLevel+1); polyline1_1 = new GPolyline.fromEncoded({ color: "#D7003D", weight: 2, opacity: 0.8, points: "ssjnGbQlEjZmn@vg@anC|LuiARsRsBimA}eAyDeXmNgIgG_THi\\cq@qs@_rBvuB}SMpx@knBzEaY_k@iq@uK_V}Te_@`VmhDhLgVqu@_^so@eq@{z@oRa{@~No_@qpC_Eu\\iIyTqL{PaAaDsiA_aBeM_qAi@{[cf@{TokAj}AiiAfDgMiPdd@m_@pO}uA[w]_rAqRwa@ya@mOcRaZ_\\{NyG{Q~N_YfoAuK`[rGlr@lSfoAmLjt@ub@tOyb@iReRaBcDd\\~DzwAuRbt@g`Bzh@eDg\\ev@ia@sGwy@tU{q@rPmPcw@oe@u{BaKwQcMvh@kfAsOuu@yLqRxEir@uq@ob@kP{KcUqXt@o]te@e[`hBke@xSgHeY{iByoAhi@egBgg@a]sh@qReIEky@`pAkqA_B{qBiHcYgd@ozCqRyCrSwd@pDwUjlCcyDd}@qYbL{WjQoM`~@iBzFlZhi@nKhr@i~AvPqPdeBxw@dwAhDv_@yL`CgV{e@idAhl@i~@sBexAdy@aaDsa@clA{SgqBkHsZceAwbBiPcOtOm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EIFFHIFHFFGIEEEGIDGFHFIEHGIEHFJFGFGGHIEFJ@FHGIGFJHHJGHFFNHEEDJFHGGFHFHEGL?IFI?AGCGFFM@HKCGHEFIGHIEHDKHIGC@IKGGDECHHFHKHEHDGIGDGHEIGP", zoomFactor: 2, numLevels: 18 }); map.setUIToDefault(); //map.addControl(new GLargeMapControl()); //map.addControl(new GScaleControl()); normalProj = G_NORMAL_MAP.getProjection(); // for conversion between LatLng and screen pixels GDir0 = new GDirections(); GDir1 = new GDirections(); // for extending route to additional point GDir2 = new GDirections(); // for recalculating of route when dragging line //GEvent.addListener(GDir1, "error", function() { alert("Directions Failed: "+GDir1.getStatus().code); }); //GEvent.addListener(GDir2, "error", function() { alert("Directions Failed: "+GDir2.getStatus().code); }); GEvent.addListener(map, 'mousemove', getProximity); // for detecting if mouse is above displayed route GEvent.addListener(map, "zoomend", function() { routeNodes = []; // clear cached coordinates in pixels of displayed route vertexes, the coordinates have to be recalculated on new zoom level }); GEvent.addListener(map, "click", function(overlay, point) { if (point) { if(waypoints.length == 2){ clearMap(); } if (waypoints.length == 0) { // Point de départ geocoder.getLocations(point, function(response){ if (!response || response.Status.code != 200) { alert("Lieu introuvable"); } else { place = response.Placemark[0]; point_precis = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]); // Décompostion pour sortir le détails d'address var tabAddress = place.address.split(','); switch(tabAddress.length) { case 1: //villeA = tabAddress[0].replace(/([0-9 \.])/g,""); villeA = tabAddress[0].replace(/([0-9\.])/g,"").trim(); lieuA = ''; break; case 2: //villeA = tabAddress[0].replace(/([0-9 \.])/g,""); villeA = tabAddress[0].replace(/([0-9\.])/g,"").trim(); lieuA = ''; break; case 3: //villeA = tabAddress[1].replace(/([0-9 \.])/g,""); villeA = tabAddress[1].replace(/([0-9\.])/g,"").trim(); lieuA = tabAddress[0]; break; } if(document.getElementById("depart_ville")) document.getElementById("depart_ville").value = villeA ; if(document.getElementById("depart_lieu")) document.getElementById("depart_lieu").value = lieuA; // recup du departement si liste select classqiue // A modifier dès que possible pour prendre en compte les selects générés if(!LISTE_DEPARTMENT_EN_DIV) recupDepartement(villeA, place.AddressDetails.Country.CountryNameCode, point_precis, 'choixDepartementDepart'); var circlePoints_depart = drawCircle(point_precis,radiusA,'KM'); searchAreaHighlight_depart = new GPolygon(circlePoints_depart, 'blue', 2 , 0.5 , '#CCC000', 0.10); map.addOverlay(searchAreaHighlight_depart); GDir1.loadFromWaypoints([point_precis.toUrlValue(6), point_precis.toUrlValue(6)], {getPolyline:true}); } }); } else if (waypoints.length == 1) { geocoder.getLocations(point, function(response){ if (!response || response.Status.code != 200) { alert("Lieu introuvable"); } else { place = response.Placemark[0]; point_precis = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); // Décompostion pour sortir le détails d'address var tabAddress = place.address.split(','); switch(tabAddress.length) { case 1: //villeB = tabAddress[0].replace(/([0-9 \.])/g,""); villeB = tabAddress[0].replace(/([0-9\.])/g,"").trim(); lieuB = ''; break; case 2: //villeB = tabAddress[0].replace(/([0-9 \.])/g,""); villeB = tabAddress[0].replace(/([0-9\.])/g,"").trim(); lieuB = ''; break; case 3: //villeB = tabAddress[1].replace(/([0-9 \.])/g,""); villeB = tabAddress[1].replace(/([0-9\.])/g,"").trim(); lieuB = tabAddress[0]; break; } if(document.getElementById("destination_ville")) document.getElementById("destination_ville").value = villeB ; if(document.getElementById("destination_lieu")) document.getElementById("destination_lieu").value = lieuB; // recup du departement si liste select classqiue // A modifier dès que possible pour prendre en compte les selects générés if(!LISTE_DEPARTMENT_EN_DIV) recupDepartement(villeB, place.AddressDetails.Country.CountryNameCode, point_precis, 'choixDepartementDestination'); var circlePoints_destination = drawCircle(point_precis,radiusB,'KM'); searchAreaHighlight_destination = new GPolygon(circlePoints_destination, 'green', 2 , 0.5 , '#00C000', 0.10); map.addOverlay(searchAreaHighlight_destination); GDir1.loadFromWaypoints([waypoints[waypoints.length-1].getPoint(), point_precis.toUrlValue(6)], {getPolyline:true}); //get directions from last waypoint to clicked point } }); } } }); iconNode = new GIcon(); iconNode.image = 'http://maps.google.com/mapfiles/ms/micons/red-pushpin.png'; iconNode.shadow = ''; iconNode.iconSize = new GSize(32,32); iconNode.shadowSize = new GSize(0,0); iconNode.iconAnchor = new GPoint(10,30); iconNode.infoWindowAnchor = new GPoint(5,5); iconNode.dragCrossImage = 'empty.gif'; // undocumented String: indicates an image to be used as the drag cross. If you set it to the null string, you get the default drag_cross_67_16.png image. iconNode.dragCrossSize = GSize(1, 1); //undocumented GSize(): indicates the size of the drag cross. iconNode.maxHeight = 1; //undocumented integer: The maximum difference in height between the marker anchor and the drag cross anchor during dragging. Setting the maxHeight to zero causes it to use the default 13. // create marker for displaying and dragging when mouse is over displayed route myNode = new GMarker(map.getCenter(), {icon:iconNode, draggable:true, bouncy:false, zIndexProcess:function(marker,b) {return 1;}}); //map.addOverlay(myNode); myNode.show(); // sometimes .hide() does not work without .show() at first ??? myNode.hide(); // hide this marker initially GEvent.addListener(myNode, "drag", function() { // mouse was over displayed route and user drags the displayed marker myNode.show(); if (isDragged == 2) { // already waiting for GDir2.load to complete - so just remember that marker was dragged again markerDragged = myNode; // remember which marker was dragged return; } if (myNode.MyIndex < waypoints.length) { isDragged = 2; // tag that GDir2.load is started markerDragged = false; lastIndex = myNode.MyIndex; prevIndex = -1; // recalculate route between waypoints before and after myNode on the displayed line GDir2.loadFromWaypoints([waypoints[lastIndex].getPoint(), myNode.getPoint().toUrlValue(6), waypoints[lastIndex + 1].getPoint()], {getPolyline:true}); } }); GEvent.addListener(myNode, "dragend", function() { // when user finished dragging the line, create new waypoint with permanent marker at the location //alert('on drag?'); var point = myNode.getPoint(); var marker = new GMarker(point, {icon:iconNode, draggable:true, dragCrossMove:false, bouncy:false, zIndexProcess:function(marker,b) {return 1;}}); waypoints.splice(myNode.MyIndex + 1, 0, marker); //insert new waypoint into waypoints array for (var i = myNode.MyIndex; i < waypoints.length; i++) // reindex next waypoints waypoints[i].MyIndex = i; var dummy = new GPolyline([point]); // insert empty segment into route segments array - GDir2.load will replace it with new route segment map.addOverlay(dummy); gpolys.splice(myNode.MyIndex + 1, 0, dummy); // add event listeners for marker of new waypoint - so route will be recalculated when user drags waypoint GEvent.addListener(marker, "dragstart", function() { isDragged = 1; myNode.hide(); }); GEvent.addListener(marker, "dragend", function() { isDragged = 0; } ); GEvent.addListener(marker, "drag", dragMarker); map.addOverlay(marker); if (myNode.MyIndex < waypoints.length) { lastIndex = myNode.MyIndex + 1; prevIndex = lastIndex - 1; // recalculate route between previous and next waypoints going through new inserted waypoint GDir2.loadFromWaypoints([waypoints[lastIndex - 1].getPoint(),point.toUrlValue(6), waypoints[lastIndex + 1].getPoint()], {getPolyline:true}); } }); // Pour affichage sur la carte lors d'une recherche par form GEvent.addListener(GDir0, "load", function() { var gp = GDir0.getPolyline(); var pointA = gp.getVertex(0); var pointB = gp.getVertex(gp.getVertexCount() - 1); var markerA = new GMarker(pointA, {icon:iconNode, draggable:true, dragCrossMove:false, bouncy:false, zIndexProcess:function(marker,b) {return 1;}}); var markerB = new GMarker(pointB, {icon:iconNode, draggable:true, dragCrossMove:false, bouncy:false, zIndexProcess:function(marker,b) {return 1;}}); markerA.title = GDir0.getRoute(0).getStartGeocode().address; markerB.title = GDir0.getRoute(0).getEndGeocode().address; GEvent.addListener(markerA, "dragstart", function() { isDragged = 1; myNode.hide(); }); GEvent.addListener(markerB, "dragstart", function() { isDragged = 1; myNode.hide(); }); GEvent.addListener(markerA, "drag", dragMarker); GEvent.addListener(markerB, "drag", dragMarker); GEvent.addListener(markerA, "dragend", function() { isDragged = 0; }); GEvent.addListener(markerB, "dragend", function() { isDragged = 0; }); markerA.MyIndex = 0; markerB.MyIndex = 1; waypoints.push(markerA); waypoints.push(markerB); map.addOverlay(markerA); map.addOverlay(markerB); var numGeoCodes = GDir1.getNumGeocodes(); if (waypoints.length > 1) { // if this was not the first waypoint - display the route to this waypoint map.addOverlay(gp); gpolys.push(gp); routeNodes = []; getProximity(); ecoov.covDansRayon((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng(), radiusA, radiusB); //ecoov.trouverParCarte((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng()); } }); GEvent.addListener(GDir1, "load", function() { var gp = GDir1.getPolyline(); var point = gp.getVertex(gp.getVertexCount() - 1); // snap to last vertex in the polyline // var marker = new GMarker(point, {icon:iconNode, draggable:true, dragCrossMove:false, bouncy:false, zIndexProcess:function(marker,b) {return 1;}}); GEvent.addListener(marker, "dragstart", function() { //alert(isDragged); isDragged = 1; myNode.hide(); // On vire les overlays rayon et cov dans rayon //mgr.clearMarkers(); //if (marker.MyIndex == 1) map.removeOverlay(searchAreaHighlight_destination); //else map.removeOverlay(searchAreaHighlight_depart); }); //GEvent.addListener(marker, "drag", dragMarker); GEvent.addListener(marker, "dragend", dragMarker); marker.MyIndex = waypoints.length; waypoints.push(marker); map.addOverlay(marker); var numGeoCodes = GDir1.getNumGeocodes(); if (waypoints.length > 1) { // if this was not the first waypoint - display the route to this waypoint map.addOverlay(gp); gpolys.push(gp); routeNodes = []; getProximity(); ecoov.covDansRayon((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng(), radiusA, radiusB); ecoov.trouverParCarte((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng()); } }); GEvent.addListener(GDir2, "load", function() { var gp = GDir2.getPolyline(); var pointBisDepart = gp.getVertex(1); // snap to last vertex in the polyline var pointBisDestination = gp.getVertex(gp.getVertexCount() - 1); // snap to last vertex in the polyline map.removeOverlay(gpolys[lastIndex]); if (prevIndex >= 0) { // not the last waypoint was dragged map.removeOverlay(gpolys[lastIndex-1]); var minD, minI, points=[]; var p0 = waypoints[lastIndex].getPoint(); for (var i = 0; i < gp.getVertexCount(); i++) { // search closest vertex to dragged waypoint for splitting received route at it into two routes between waypoints var p = gp.getVertex(i); points.push(p); var d = p0.distanceFrom(p); if (i == 0 || minD > d) { minD = d; minI = i; } } gpolys[lastIndex - 1] = new GPolyline(points.slice(0, minI + 1)); //+1, because slice extracts up to, but not including, the 'end' element gpolys[lastIndex] = new GPolyline(points.slice(minI, points.length)); map.addOverlay(gpolys[lastIndex - 1]); waypoints[lastIndex-1].title = GDir2.getRoute(0).getStartGeocode().address; waypoints[lastIndex].title = GDir2.getRoute(0).getEndGeocode().address; waypoints[lastIndex+1].title = GDir2.getRoute(1).getEndGeocode().address; } else { // last waypoint was dragged gpolys[lastIndex] = gp; waypoints[lastIndex].title = GDir2.getRoute(0).getStartGeocode().address; waypoints[lastIndex+1].title = GDir2.getRoute(0).getEndGeocode().address; } map.addOverlay(gpolys[lastIndex]); routeNodes = []; getProximity(); isDragged = 0; // tag that there is no dragged waypoints or waiting for GDir to complete if (markerDragged) { // marker was dragged again until GDir2 was loaded isDragged = 1; // tag that there is dragged waypoint GEvent.trigger(markerDragged, 'drag'); // trigger recalculation of route } mgr.clearMarkers(); ecoov.covDansRayon((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng(), radiusA, radiusB); ecoov.trouverParCarte((waypoints[0].getLatLng()).lat(), (waypoints[0].getLatLng()).lng(), (waypoints[waypoints.length-1].getLatLng()).lat(), (waypoints[waypoints.length-1].getLatLng()).lng()); }); } } function dragMarker() { // when waypoint marker is being dragged, start calculation of new route if (isDragged == 2) { // exit if already waiting for GDir2.load to complete markerDragged = this; return; } isDragged = 2; // tag that calculation of new route is started if (markerDragged) { //determine which marker triggered the recalculation marker = markerDragged; markerDragged = false; } else { marker = this; } lastIndex = marker.MyIndex; var point = marker.getPoint(); if (lastIndex > 0) { if (lastIndex < waypoints.length - 1) { prevIndex = lastIndex - 1; geocoder.getLocations(point, function(response){ if (!response || response.Status.code != 200) { alert("Lieu introuvable"); } else { place = response.Placemark[0]; point_precis = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); GDir2.loadFromWaypoints([waypoints[lastIndex - 1].getPoint(),point_precis.toUrlValue(6),waypoints[lastIndex + 1].getPoint()],{getPolyline:true}); } }); } else { prevIndex = -1; lastIndex = lastIndex - 1; geocoder.getLocations(point, function(response){ if (!response || response.Status.code != 200) { alert("Lieu introuvable"); } else { place = response.Placemark[0]; point_precis = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); // Décompostion pour sortir le détails d'address var tabAddress = place.address.split(','); switch(tabAddress.length) { case 1: villeB = tabAddress[0].replace(/([0-9 \.])/g,""); lieuB = ''; break; case 2: villeB = tabAddress[0].replace(/([0-9 \.])/g,""); lieuB = ''; break; case 3: villeB = tabAddress[1].replace(/([0-9 \.])/g,""); lieuB = tabAddress[0]; break; } if(document.getElementById("destination_ville")) document.getElementById("destination_ville").value = villeB ; if(document.getElementById("destination_lieu")) document.getElementById("destination_lieu").value = lieuB; // recup du departement si liste select classqiue // A modifier dès que possible pour prendre en compte les selects générés if(!LISTE_DEPARTMENT_EN_DIV) recupDepartement(villeB, place.AddressDetails.Country.CountryNameCode, point_precis, 'choixDepartementDestination'); map.removeOverlay(searchAreaHighlight_destination); var circlePoints_destination = drawCircle(point_precis,radiusB,'KM'); searchAreaHighlight_destination = new GPolygon(circlePoints_destination, 'green', 2 , 0.5 , '#CCC000', 0.10); map.addOverlay(searchAreaHighlight_destination); GDir2.loadFromWaypoints([waypoints[lastIndex].getPoint(),point_precis.toUrlValue(6)],{getPolyline:true}); } }); } } else if (waypoints.length > 1) { prevIndex = -1; geocoder.getLocations(point, function(response){ if (!response || response.Status.code != 200) { alert("Lieu introuvable"); } else { place = response.Placemark[0]; point_precis = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); // Décompostion pour sortir le détails d'address var tabAddress = place.address.split(','); switch(tabAddress.length) { case 1: villeA = tabAddress[0].replace(/([0-9 \.])/g,""); lieuA = ''; break; case 2: villeA = tabAddress[0].replace(/([0-9 \.])/g,""); lieuA = ''; break; case 3: villeA = tabAddress[1].replace(/([0-9 \.])/g,""); lieuA = tabAddress[0]; break; } if(document.getElementById("depart_ville")) document.getElementById("depart_ville").value = villeA ; if(document.getElementById("depart_lieu")) document.getElementById("depart_lieu").value = lieuA; // recup du departement si liste select classqiue // A modifier dès que possible pour prendre en compte les selects générés if(!LISTE_DEPARTMENT_EN_DIV) recupDepartement(villeA, place.AddressDetails.Country.CountryNameCode, point_precis, 'choixDepartementDepart'); map.removeOverlay(searchAreaHighlight_depart); var circlePoints_depart = drawCircle(point_precis,radiusA,'KM'); searchAreaHighlight_depart = new GPolygon(circlePoints_depart, 'blue', 2 , 0.5 , '#CCC000', 0.10); map.addOverlay(searchAreaHighlight_depart); mgr.clearMarkers(); GDir2.loadFromWaypoints([point_precis.toUrlValue(6),waypoints[1].getPoint()],{getPolyline:true}); } }); } } function getProximity(mouseLatLng, marker) { // detecting if mouse is over displayed route var dist, zoom; if (routeNodes.length == 0) { // calculate and cache coordinates of displayed polylines in pixels for better performance in routeNodes array dist = 0; zoom = map.getZoom(); if (gpolys.length > 0 && gpolys[0].getVertexCount() > 0 ) //store first point routeNodes.push(normalProj.fromLatLngToPixel(gpolys[0].getVertex(0), zoom)); for (var i = 0; i < gpolys.length; i++) { dist += gpolys[i].getLength(); for (var j = 1; j < gpolys[i].getVertexCount(); j++) { var point = normalProj.fromLatLngToPixel(gpolys[i].getVertex(j), zoom) point.MyIndex = i; // store the index of polyline containing this node routeNodes.push(point); } } // display route length if 'panel' element is present var panel = document.getElementById('panel'); if (panel) { panel.innerHTML = (dist/1000).toFixed(1) + " km"; } } if (!mouseLatLng || routeNodes.length <= 1 || isDragged > 0) // no route is displayed or route is already being dragged return; zoom = map.getZoom(); var mousePx = normalProj.fromLatLngToPixel(mouseLatLng, zoom); var minDist = 999; var minX = mousePx.x; // we will search closest point on the line to mouse position for displaying marker there available for dragging var minY = mousePx.y; if (routeNodes.length > 1) { var x,y, d1,d2,d; var dx = mousePx.x - routeNodes[0].x; var dy = mousePx.y - routeNodes[0].y; d2 = dx*dx + dy*dy; // distance^2 from mouse to start of segment 1 in pixels for (var n = 0 ; ++n < routeNodes.length; ) { d1 = d2; // distance^2 from mouse to start of segment n in pixels x = routeNodes[n].x; dx = mousePx.x - x; y = routeNodes[n].y; dy = mousePx.y - y; d2 = dx*dx + dy*dy; // distance^2 from mouse to end of segment n in pixels dx = x - routeNodes[n-1].x; dy = y - routeNodes[n-1].y; d = dx*dx + dy*dy; // lenght^2 of segment n var u = ((mousePx.x - x) * dx + (mousePx.y - y) * dy) / d; // a bit of vector algebra :) x += (u*dx); // x,y coordinates in pixels of closest point to mouse in segment n y += (u*dy); dx = mousePx.x - x; dy = mousePx.y - y; dist = dx*dx + dy*dy; // distance^2 from mouse to closest point in segment n if ((d1 - dist) + (d2 - dist) > d) { // closest point is outside the segment, so the real closest point is either start or end of segment if (d1 < d2) { dist = d1; x = routeNodes[n-1].x; y = routeNodes[n-1].y; } else { dist = d2; x = routeNodes[n].x; y = routeNodes[n].y; } }; if (minDist > dist) { // closest point in segment n is closest point overall so far minDist = dist; minX = x; minY = y; myNode.MyIndex = routeNodes[n].MyIndex; // remember segment closest to mouse } } if (minDist > 25) { // mouse is not close enough to the displayed line myNode.hide(); // do not display marker for dragging the polyline } else { for (n = waypoints.length; --n >= 0;) { // check if mouse is not too close to existing waypoints markers var markerPx = normalProj.fromLatLngToPixel(waypoints[n].getPoint(), zoom); dx = markerPx.x - minX; dy = markerPx.y - minY; if (dx*dx + dy*dy < 25) { // mouse is too close to existing marker myNode.hide(); // do not show additional marker for dragging the line - the user is about to drag existing waypoint return; } } myNode.setPoint(normalProj.fromPixelToLatLng(new GPoint(minX, minY), zoom)); myNode.show(); // display marker for dragging the polyline } //document.getElementById('panel').innerHTML = '
Mouse distance to line ' + n + ': ' + minDist.toFixed(2); } } // Création des markers function creationMarkers(point, address, mode) { // Création de mini icones var icon = new GIcon(); if (mode == 'depart') icon.image = 'http://maps.google.com/mapfiles/kml/pal4/icon57.png'; else if(mode == 'destination') icon.image = 'http://maps.google.com/mapfiles/kml/pal4/icon56.png'; icon.iconSize = new GSize(20, 20); icon.iconAnchor = new GPoint(10, 10); icon.infoWindowAnchor = new GPoint(5, 1); var marker = new GMarker(point, {icon: icon, zIndexProcess:function(marker,b) {return 2;}}); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(address); } ); return marker; } function importanceOrder (marker,b) { marker.importance = 1; return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000; } function drawCircle(center,circleRadius,circleUnits){ var circlePoints = Array(); with (Math) { if (circleUnits == 'KM') { var rLat = (circleRadius/6378.8) * (180/PI); } else { //miles var rLat = (circleRadius/3963.189) * (180/PI); } var rLng = rLat/cos(center.lat() * (PI/180)); for (var a = 0 ; a < 361 ; a+=1 ) { var aRad = a*(PI/180); var x = center.lng() + (rLng * cos(aRad)); var y = center.lat() + (rLat * sin(aRad)); var point = new GLatLng(parseFloat(y),parseFloat(x)); circlePoints.push(point); } } return circlePoints; } function loadGmapOffre(depart, destination, etapes) { carteOffre = new GMap2(document.getElementById("carteDetail"), {draggableCursor:"crosshair"}); carteOffre.setCenter(new GLatLng('44.172355652','0.450237006'), 7); mgr_ = new MarkerManager(carteOffre); normalProj = G_NORMAL_MAP.getProjection(); carteOffre.enableDoubleClickZoom(); carteOffre.setUIToDefault(); var waypointsDetails = []; // Decompositon du table de depart var tab_depart = depart.split('/'); point_depart = new GLatLng(tab_depart[0], tab_depart[1]); waypointsDetails.push(point_depart); // Decomposition pour étapes etapes.each(function(str){ var e = str.split('/'); waypointsDetails.push(new GLatLng(e[0], e[1])); }); // Decompositon du table de destination var tab_destination = destination.split('/'); point_destination = new GLatLng(tab_destination[0], tab_destination[1]); waypointsDetails.push(point_destination); /* var circlePoints_depart = drawCircle(point_depart,5,'MI'); searchAreaHighlight_depart = new GPolygon(circlePoints_depart, 'blue', 2 , 0.5 , '#CCC000', 0.10); carteOffre.addOverlay(searchAreaHighlight_depart); var circlePoints_depart = drawCircle(point_destination,5,'MI'); searchAreaHighlight_depart = new GPolygon(circlePoints_depart, 'green', 2 , 0.5 , '#00C000', 0.10); carteOffre.addOverlay(searchAreaHighlight_depart); */ directionsDetail = new GDirections(carteOffre); directionsDetail.loadFromWaypoints(waypointsDetails); GEvent.addListener(directionsDetail, "addoverlay", function() { directionsDetail.getPolyline().hidden = false; //carteOffre.setZoom(carteOffre.getZoom()-1); //ecoov.covDansRayon(lat_depart, lng_depart, lat_destination, lng_destination, 20, 20); }); } function loadGmapRecherche(lat_depart, lng_depart, lat_destination, lng_destination, radius_depart, radius_destination) { if(lat_depart && lat_destination) { clearMap(); mgr = new MarkerManager(map); var waypointsDetails = []; point_depart = new GLatLng(lat_depart, lng_depart); point_destination = new GLatLng(lat_destination, lng_destination); var circlePoints_depart = drawCircle(point_depart,radius_depart,'MI'); searchAreaHighlight_depart = new GPolygon(circlePoints_depart, 'blue', 2 , 0.5 , '#CCC000', 0.10); map.addOverlay(searchAreaHighlight_depart,{zIndexProcess:1000}); var circlePoints_depart = drawCircle(point_destination,radius_destination,'MI'); searchAreaHighlight_destination = new GPolygon(circlePoints_depart, 'green', 2 , 0.5 , '#00C000', 0.10); map.addOverlay(searchAreaHighlight_destination,{zIndexProcess:1000}); waypointsDetails.push(point_depart); waypointsDetails.push(point_destination); directionsDetail = new GDirections(map); directionsDetail.loadFromWaypoints(waypointsDetails); GEvent.addListener(directionsDetail, "addoverlay", function() { directionsDetail.getPolyline().hidden = false; map.setZoom(map.getZoom()-1); if(radius_depart != 0 || radius_destination != 0) ecoov.covDansRayon(lat_depart, lng_depart, lat_destination, lng_destination, radius_depart, radius_destination); }); } } function clearMap() { map.clearOverlays(); if(poly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f}ECp@qDb`ICf\\yEr[mXvpClErtBbU`r@eE`yAmUJkbHtAwsC`dAuJ{Vae@kcAgf@ePnJ{Wz^ea@nJsv@gh@geBuoA}~An\\mf@mNiO}fBubAgLiVie@ecB}vB~x@_Uoq@ujCbkC{sAj_CmInOqSl`@ocBkj@nBcy@wi@a_A]wrBoCo[@kV`CuUycAkoBiAqy@lW}oA{k@gx@_g@v~@i]ud@wRkJuMpN{b@jx@qnCzqBmXei@gRdGwf@zFwu@{[gNmo@wN_Pqx@zQ}Tfm@", levels: "PGHEDJGEEFGIFKEHECHFJFHGIBGDCEHDJHHJGGEIGCBELFDHDGIGEIEFIKGHGEIGFIHEGIAEJFGCIJHGEMGIGDGIDFKFEHGGIEIHFKFHGGIFDGEHHAEIGEFJFHHIEFIGGBJHCGIDJBFEFGHHIGGLGIGBHGEJEGGHHJFFHHKDEDIIHDBFFHEHKGEHEBGGHOCFHFECHIDHGLFGGIGHDIEFFFIGHGFDJFFHDHHHGLGGGFIHHFEJBHFJECCHFDLGFIEGEHFKGFHBICGFKDHIHHFIJDHEBKHFGGIEFGGLHGIGFHFKAHFGJFFHFIFGGGFJFHCGHHFNGHGEHGGKEGGEEIFFHIFHFFGIEEEGIDGFHFIEHGIEHFJFGFGGHIEFJ@FHGIGFJHHJGHFFNHEEDJFHGGFHFHEGL?IFI?AGCGFFM@HKCGHEFIGHIEHDKHIGC@IKGGDECHHFHKHEHDGIGDGHEIGP", zoomFactor: 2, numLevels: 18 }); map.addOverlay(polyline1_1); */ waypoints=[]; gpolys=[]; //routeNodes=[]; stateSilder=0; } function rmOverlays() { countyLines = Array(); map.clearOverlays(); map.addOverlay(texasMask); resizePage(); startMarker = null; endMarker = null; pLinePoints = Array(); map.addOverlay(polyline1_1); } function showAddress(response) { //map.clearOverlays(); if (!response || response.Status.code != 200) { alert("Status Code:" + response.Status.code); } else { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); marker = new GMarker(point); map.addOverlay(marker); marker.openInfoWindowHtml( 'orig latlng:' + response.name + '
' + 'latlng:' + place.Point.coordinates[0] + "," + place.Point.coordinates[1] + '
' + 'Status Code:' + response.Status.code + '
' + 'Status Request:' + response.Status.request + '
' + 'Address:' + place.address + '
' + 'Accuracy:' + place.AddressDetails.Accuracy + '
' + 'Country code: ' + place.AddressDetails.Country.CountryNameCode); return point; } } function recupDepartement(ville, pays, coor, lst_nom){ // On execute que si un select dep existe if($(lst_nom)) { var params = 'html=1&ville='+ville+'&pays='+pays+'&coor='+coor; var req = GXmlHttp.create(); req.open("POST", path+"/include/recherche/recherche_departement-carte.php", true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", params.length+10); req.setRequestHeader("Connection", "close"); req.send(params); req.onreadystatechange = function () { if (req.readyState == 4) { if (req.status == 200) { var lst = $(lst_nom).getFirst().getChildren(); lst.each(function(el){ (el.value == req.responseText) ? el.selected = 'selected' : el.selected = ''; }); } } } } else return ''; } //carto covoiturage-plages var geocoder = null; var map = null; var icon = new GIcon(); icon.iconSize = new GSize(24,30); icon.iconAnchor = new GPoint(24,30); icon.infoWindowAnchor = new GPoint(12, 0); icon.image = "/images/puce-25.png"; var etoile = new GIcon(); etoile.iconSize = new GSize(30,25); etoile.iconAnchor = new GPoint(30,25); etoile.infoWindowAnchor = new GPoint(12, 0); etoile.image = "/images/etoile.png"; var pavillon = new GIcon(); pavillon.iconSize = new GSize(40,40); pavillon.iconAnchor = new GPoint(20,40); pavillon.infoWindowAnchor = new GPoint(20, 0); pavillon.image = "/images/pavillon.png"; var etoile_pavillon = new GIcon(); etoile_pavillon.iconSize = new GSize(65,40); etoile_pavillon.iconAnchor = new GPoint(32,40); etoile_pavillon.infoWindowAnchor = new GPoint(32, 0); etoile_pavillon.image = "/images/etoile_pavillon.png"; function createMarkerPlage(insee,nom,partenariat) { if(partenariat!="2"){ var maplage = "http://maplage.fr/api/plage/id/"+insee; GDownloadUrl(maplage, function(data, responseCode) { if(responseCode == 200) { var xmlDoc = GXml.parse(data); var plages = xmlDoc.documentElement.getElementsByTagName("plage"); for (var i = 0; i < plages.length; i++) { var nom_plage = plages[i].getAttribute("nom"); var adresse_plage = plages[i].getAttribute("nom") + " " + nom; geoloc(adresse_plage,1); } } }); } if(partenariat!="1"){ var pavillon = "/includus/php/plages_pav_xml.php?insee="+insee; GDownloadUrl(pavillon, function(data, responseCode) { if(responseCode == 200) { var xmlDoc = GXml.parse(data); var plages = xmlDoc.documentElement.getElementsByTagName("plage"); for (var i = 0; i < plages.length; i++) { var adresse_plage = plages[i].getAttribute("adresse") + " " + nom; geoloc(adresse_plage,2); } } }); } } function geoloc(adresse,partenaire){ //partenaire : //1->maplage //2->pavillon if (geocoder) { geocoder.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { if(partenaire==1){ var marker = new GMarker(point,etoile); }else if(partenaire==2){ var marker = new GMarker(point,pavillon); } map.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function loadGmapPlages() { if (GBrowserIsCompatible()) { var style = [{ url: '/images/para-40.png', height: 40 , width: 32, opt_anchor: [22, 0], opt_textColor: '#FFF' }, { url: '/images/para-45.png', height: 45, width: 36, opt_anchor: [26, 0], opt_textColor: '#FFF' }, { url: '/images/para-55.png', height: 55, width: 44, opt_anchor: [34, 0], opt_textColor: '#FFF' }]; var gmarkers = []; function modif_bulle(nom_plage){ html+=nom_plage+"
"; } function createMarker(point,nom,insee,partenariat) { var meteo = ""; switch(partenariat) { case "1": var marker = new GMarker(point, {icon: etoile}); meteo = '

Voir la météo de cette ville

'; break; case "2": var marker = new GMarker(point, {icon: pavillon}); break; case "3": var marker = new GMarker(point, {icon: etoile_pavillon}); meteo = '

Voir la météo de cette ville

'; break; default: var marker = new GMarker(point, {icon: icon}); } GEvent.addListener(marker, "click", function() { //var html = '
'+nom.toUpperCase()+'
Voir les plages
Partir de cette ville
Se rendre dans cette ville
'; var html = '
'+nom.toUpperCase()+'
'+meteo+'
'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map = new GMap2(document.getElementById("carte")); map.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.enableScrollWheelZoom(); geocoder = new GClientGeocoder(); GDownloadUrl("/includus/php/plages_xml.php", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var insee = markers[i].getAttribute("insee"); var partenariat = markers[i].getAttribute("partenariat"); var marker = createMarker(point,nom,insee,partenariat); } var markerCluster = new MarkerClusterer(map, gmarkers, {styles: style}); }); } } //carto v2 var geocoder = null; var map = null; var style = [{ url: '/media/site/image/voiture40.png', height: 25 , width: 40, opt_anchor: [10, 0], opt_textColor: '#FFF' }, { url: '/media/site/image/voiture45.png', height: 28, width: 45, opt_anchor: [12, 0], opt_textColor: '#FFF' }, { url: '/media/site/image/voiture55.png', height: 34, width: 55, opt_anchor: [18, 0], opt_textColor: '#FFF' }]; function geolocV2(adresse,partenaire){ if (geocoder) { geocoder.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { var marker = new GMarker(point,icon); map.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function loadGmapV2() { if (GBrowserIsCompatible()) { var icon_google = new GIcon(G_DEFAULT_ICON); icon_google.image = "/media/site/image/puce.png"; var gmarkers = []; function createMarker(point,nom,nb) { var marker = new GMarker(point, {icon: icon_google}); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map = new GMap2(document.getElementById("carteIndex")); map.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map.setUIToDefault(); map.setMapType(G_PHYSICAL_MAP); geocoder = new GClientGeocoder(); GDownloadUrl("/includus/xml/trajet-bdd.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var nb = parseFloat(markers[i].getAttribute("nb")); var marker = createMarker(point,nom,nb); } var markerCluster = new MarkerClusterer(map, gmarkers, {styles: style}); }); } } //carto cg29 var geocoder29 = null; var map29 = null; var aire = new GIcon(); aire.iconSize = new GSize(25,25); aire.iconAnchor = new GPoint(12,25); aire.infoWindowAnchor = new GPoint(12, 0); aire.image = "/media/site/image/airecovoiturage.png"; function geolocCG29(adresse,partenaire){ if (geocoder29) { geocoder29.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { var marker = new GMarker(point,icon); map29.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function affichelisting(ville,depdest){ if(depdest==1){ $('depart_ville').value=ville; $('destination_ville').value=""; }else{ $('depart_ville').value=""; $('destination_ville').value=ville; } var rAjax = new Request.HTML({ url:path+'/include/recherche/recherche_form-trait.php?xhr=1', evalScripts: false }).post($('form_choix_ville')); rAjax.addEvent('onComplete', function(esponseTree, responseElements, responseHTML, responseJavaScript){ if ($('ville-select') && $('ville-select').value != '') { ecoov.findCp($('ville-select').value); } $('listingOffres').set('html', responseHTML); if(responseJavaScript) $exec(responseJavaScript); if($('menuRss')) { $('menuRss').setStyle('display', 'block'); ecoov.alerteCriteres(); } ecoov.voirDetailsOffre(); }); } function afficheListingDepartement(ville,depdest,departement){ if(depdest==1){ $('depart_ville').value=ville; $('destination_ville').value=""; $('choixDepartementDepart').set('value', departement); }else{ $('depart_ville').value=""; $('destination_ville').value=ville; $('choixDepartementDestination').set('value', departement); } var rAjax = new Request.HTML({ url:path+'/include/recherche/recherche_form-trait.php?xhr=1', evalScripts: false }).post($('form_choix_ville')); rAjax.addEvent('onComplete', function(esponseTree, responseElements, responseHTML, responseJavaScript){ if ($('ville-select') && $('ville-select').value != '') { ecoov.findCp($('ville-select').value); } $('listingOffres').set('html', responseHTML); if(responseJavaScript) $exec(responseJavaScript); if($('menuRss')) { $('menuRss').setStyle('display', 'block'); ecoov.alerteCriteres(); } ecoov.voirDetailsOffre(); }); } function loadGmapCG29() { if (GBrowserIsCompatible()) { var icon = new GIcon(G_DEFAULT_ICON); icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png"; var gmarkers = []; function createMarker(point,nom,nb_dep,nb_dest) { var marker = new GMarker(point, {icon: icon}); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

Trajet(s) à partir de cette destination
Trajet(s) jusqu\'à de cette destination
'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map29 = new GMap2(document.getElementById("carte2")); map29.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map29.addControl(new GLargeMapControl()); map29.addControl(new GMapTypeControl()); map29.enableScrollWheelZoom(); geocoder29 = new GClientGeocoder(); var mgr = new MarkerManager(map29); GDownloadUrl("/includus/xml/trajet.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var nb_dep = parseFloat(markers[i].getAttribute("nb_dep")); var nb_dest = parseFloat(markers[i].getAttribute("nb_dest")); var marker = createMarker(point,nom,nb_dep,nb_dest); } var markerCluster = new MarkerClusterer(map29, gmarkers, {icons: icon}); }); function createMarkerAireCovoiturage(point,nom,adresse) { var marker = new GMarker(point,aire); //map29.addOverlay(marker); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

'+''+adresse+''; marker.openInfoWindowHtml(html); }); return marker; } GDownloadUrl("/includus/xml/airecovoiturage.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); var markers2 = []; for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var adresse = markers[i].getAttribute("adresse"); markers2.push(createMarkerAireCovoiturage(point,nom,adresse)); } mgr.addMarkers(markers2,10); mgr.refresh(); } ); } } //carto cg22 var geocoder22 = null; var map22 = null; var aire = new GIcon(); aire.iconSize = new GSize(25,25); aire.iconAnchor = new GPoint(12,25); aire.infoWindowAnchor = new GPoint(12, 0); aire.image = "/media/site/image/airecovoiturage.png"; function geolocCG22(adresse,partenaire){ if (geocoder22) { geocoder22.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { var marker = new GMarker(point,icon); map22.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function loadGmapCG22() { if (GBrowserIsCompatible()) { var icon = new GIcon(G_DEFAULT_ICON); icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png"; var gmarkers = []; function createMarker(point,nom,nb_dep,nb_dest) { var marker = new GMarker(point, {icon: icon}); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

Trajet(s) à partir de cette destination
Trajet(s) jusqu\'à de cette destination
'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map22 = new GMap2(document.getElementById("carte2")); map22.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map22.addControl(new GLargeMapControl()); map22.addControl(new GMapTypeControl()); map22.enableScrollWheelZoom(); geocoder22 = new GClientGeocoder(); var mgr = new MarkerManager(map22); GDownloadUrl("/includus/xml/trajet.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var nb_dep = parseFloat(markers[i].getAttribute("nb_dep")); var nb_dest = parseFloat(markers[i].getAttribute("nb_dest")); var marker = createMarker(point,nom,nb_dep,nb_dest); } var markerCluster = new MarkerClusterer(map22, gmarkers, {icons: icon}); }); function createMarkerAireCovoiturage(point,nom,adresse) { var marker = new GMarker(point,aire); //map22.addOverlay(marker); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

'+''+adresse+''; marker.openInfoWindowHtml(html); }); return marker; } GDownloadUrl("/includus/php/aire_covoiturage_xml.php", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); var markers2 = []; for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var adresse = markers[i].getAttribute("adresse"); markers2.push(createMarkerAireCovoiturage(point,nom,adresse)); } mgr.addMarkers(markers2,10); mgr.refresh(); } ); } } //carto cg76 var geocoder76 = null; var map76 = null; var aire = new GIcon(); aire.iconSize = new GSize(25,25); aire.iconAnchor = new GPoint(12,25); aire.infoWindowAnchor = new GPoint(12, 0); aire.image = "/media/site/image/airecovoiturage.png"; function geolocCG76(adresse,partenaire){ if (geocoder76) { geocoder76.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { var marker = new GMarker(point,icon); map76.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function loadGmapCG76() { if (GBrowserIsCompatible()) { var icon = new GIcon(G_DEFAULT_ICON); icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png"; var gmarkers = []; function createMarker(point,nom,nb_dep,nb_dest,depart_departement) { var marker = new GMarker(point, {icon: icon}); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

Trajet(s) à partir de cette destination
Trajet(s) jusqu\'à de cette destination
'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map76 = new GMap2(document.getElementById("carte2")); map76.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map76.setUIToDefault(); //map76.addControl(new GLargeMapControl()); //map76.addControl(new GMapTypeControl()); //map76.enableScrollWheelZoom(); geocoder76 = new GClientGeocoder(); var mgr = new MarkerManager(map76); GDownloadUrl("/includus/xml/trajet.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var nb_dep = parseFloat(markers[i].getAttribute("nb_dep")); var nb_dest = parseFloat(markers[i].getAttribute("nb_dest")); var depart_departement = parseFloat(markers[i].getAttribute("depart_departement")); var marker = createMarker(point,nom,nb_dep,nb_dest,depart_departement); } var markerCluster = new MarkerClusterer(map76, gmarkers, {icons: icon}); }); function createMarkerAireCovoiturage(point,nom,adresse) { var marker = new GMarker(point,aire); //map76.addOverlay(marker); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

'+''+adresse+''; marker.openInfoWindowHtml(html); }); return marker; } GDownloadUrl("/includus/php/aire_covoiturage_xml.php", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); var markers2 = []; for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var adresse = markers[i].getAttribute("adresse"); markers2.push(createMarkerAireCovoiturage(point,nom,adresse)); } mgr.addMarkers(markers2,10); mgr.refresh(); } ); } } //carto cg27 var geocoder27 = null; var map27 = null; var aire = new GIcon(); aire.iconSize = new GSize(25,25); aire.iconAnchor = new GPoint(12,25); aire.infoWindowAnchor = new GPoint(12, 0); aire.image = "/media/site/image/airecovoiturage.png"; function geolocCG27(adresse,partenaire){ if (geocoder27) { geocoder27.getLatLng( adresse, function(point) { if (!point) { //console.log("erreur "+ adresse); } else { var marker = new GMarker(point,icon); map27.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(adresse); return marker; }); } } ); } } function loadGmapCG27() { if (GBrowserIsCompatible()) { var icon = new GIcon(G_DEFAULT_ICON); icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png"; var gmarkers = []; function createMarker(point,nom,nb_dep,nb_dest) { var marker = new GMarker(point, {icon: icon}); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

Trajet(s) à partir de cette destination
Trajet(s) jusqu\'à de cette destination
'; marker.openInfoWindowHtml(html); }); gmarkers.push(marker); return marker; } // Création de la carte map27 = new GMap2(document.getElementById("carte2")); map27.setCenter(new GLatLng('44.172355652','0.450237006'), 9); map27.setUIToDefault(); //map27.addControl(new GLargeMapControl()); //map27.addControl(new GMapTypeControl()); //map27.enableScrollWheelZoom(); geocoder27 = new GClientGeocoder(); var mgr = new MarkerManager(map27); GDownloadUrl("/includus/xml/trajet.xml", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var nb_dep = parseFloat(markers[i].getAttribute("nb_dep")); var nb_dest = parseFloat(markers[i].getAttribute("nb_dest")); var marker = createMarker(point,nom,nb_dep,nb_dest); } var markerCluster = new MarkerClusterer(map27, gmarkers, {icons: icon}); }); function createMarkerAireCovoiturage(point,nom,adresse) { var marker = new GMarker(point,aire); //map27.addOverlay(marker); GEvent.addListener(marker, "click", function() { var html = '

'+nom+'

'+''+adresse+''; marker.openInfoWindowHtml(html); }); return marker; } GDownloadUrl("/includus/php/aire_covoiturage_xml.php", function(doc) { var xmlDoc = GXml.parse(doc); var markers = xmlDoc.documentElement.getElementsByTagName("marker"); var markers2 = []; for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var nom = markers[i].getAttribute("nom"); var adresse = markers[i].getAttribute("adresse"); markers2.push(createMarkerAireCovoiturage(point,nom,adresse)); } mgr.addMarkers(markers2,10); mgr.refresh(); } ); } }