/* Version utilisant Google Maps API v3 */ /* Gestion des cartes dans l'applicatinon */ // Enable the visual refresh //google.maps.visualRefresh = true; var Currentinfowindow = null; function addMarkerSimple(IDx, Latitude, Longitude, Title, Description, X, Y, Commune, Comm_ID) { var iconorange = { url: "img/symbol/orange_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; var infowindow = new google.maps.InfoWindow({ content: "
"+Title+"
"+Description+"
Coordonnées : "+X+", "+Y+"
Commune : "+Commune+" ("+Comm_ID+")
" }); // ajout d'un marker à la carte et ajout à l'array (push) var marker = new google.maps.Marker({ position: new google.maps.LatLng(Latitude, Longitude), icon: iconorange, title: Title + ' ('+Commune+')', map: map }); google.maps.event.addListener(marker, 'click', function() { if (Currentinfowindow != null) { Currentinfowindow.close(); Currentinfowindow = null; } infowindow.open(map, marker); Currentinfowindow = infowindow; }); google.maps.event.addListener(marker, 'dblclick', function() { remove_prov_site(IDx, marker); }); markers.push(marker); } function addMarkerSimpleView(IDx, Latitude, Longitude, Title, Description, X, Y, Commune, Comm_ID) { var iconorange = { url: "img/symbol/orange_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; var infowindow = new google.maps.InfoWindow({ content: "
"+Title+"
"+Description+"
Coordonnées : "+X+", "+Y+"
Commune : "+Commune+" ("+Comm_ID+")
" }); // ajout d'un marker à la carte et ajout à l'array (push) var marker = new google.maps.Marker({ position: new google.maps.LatLng(Latitude, Longitude), icon: iconorange, title: Title + ' ('+Commune+')', map: map }); google.maps.event.addListener(marker, 'click', function() { if (Currentinfowindow != null) { Currentinfowindow.close(); Currentinfowindow = null; } infowindow.open(map, marker); Currentinfowindow = infowindow; }); markers.push(marker); } function addMarkerSimpleProject(IDx, Latitude, Longitude, Title, Description, X, Y, Commune, Comm_ID, Project, Project_ID, Status) { // icone pour les projets dont le statut est indéterminé var iconbleu = { url: "img/symbol/bleu_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; // icone pour les projets en cours var iconorange = { url: "img/symbol/orange_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; // icone pour les projets projetés var iconrouge = { url: "img/symbol/rouge_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; // icone pour les projets achevés var iconvert = { url: "img/symbol/vert_small.png", size : new google.maps.Size(16, 16), origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(8, 8) }; if (Status == '2') { // projet achevé imageicon = iconvert; } else if (Status == '3') { // projet en cours imageicon = iconorange; } else if (Status == '4') { // projet projeté imageicon = iconrouge; } else { // projet au status indéterminé imageicon = iconbleu; } var infowindow = new google.maps.InfoWindow({ content: "
"+Title+"
"+Description+"
Coordonnées : "+X+", "+Y+"
Commune : "+Commune+" ("+Comm_ID+")

Projet : "+Project+"
" }); // ajout d'un marker à la carte et ajout à l'array (push) var marker = new google.maps.Marker({ position: new google.maps.LatLng(Latitude, Longitude), icon: imageicon, title: Title + ' ('+Commune+')', map: map }); google.maps.event.addListener(marker, 'click', function() { if (Currentinfowindow != null) { Currentinfowindow.close(); Currentinfowindow = null; } infowindow.open(map, marker); Currentinfowindow = infowindow; }); markers.push(marker); } function removeMarker(IDx) { map.removeOverlay(markers[IDx]); remove_prov_site(IDx); } // Conversion des couples latitude/longitue en coordonnées suisses function LatToCHCoords(lat, lng){ var phi = lat * 3600; var lbd = lng * 3600; var phiprim = (phi - 169028.66) / 10000.0; var lbdprim = (lbd - 26782.5) / 10000.0; var x = 200147.07 + 308807.95 * phiprim + 3745.25 * lbdprim * lbdprim + 76.63 * phiprim * phiprim -194.56 * lbdprim * lbdprim * phiprim + 119.79 * phiprim * phiprim * phiprim; var y = 600072.37 + 211455.93 * lbdprim - 10938.51 * lbdprim * phiprim - 0.36 * lbdprim * phiprim * phiprim - 44.54 * lbdprim * lbdprim * lbdprim; var newCoords = new Array(y,x); return newCoords; } // Conversion des coordonnées suisses (X/Y) en couples latitude/longitude function CHtoWorld (Y, X){ // Etape 1 var Yp = (Y - 600000.0)/1000000.0; var Xp = (X - 200000.0)/1000000.0; // Etape 2 var lambda = 2.6779094 + 4.728982 * Yp + 0.791484 * Yp * Xp + 0.1306 * Yp * Xp * Xp - 0.0436 * Yp * Yp * Yp; var phi = 16.9023892 + 3.238272 * Xp - 0.270978 * Yp * Yp - 0.002528 * Xp * Xp - 0.0447 * Yp * Yp * Xp - 0.014 * Xp * Xp * Xp; // Etape 3 lambda = lambda * 100.0 / 36.0; phi = phi * 100.0 / 36.0; var newCoords = new Array(phi, lambda); return newCoords; } _mSvgEnabled = false; var normalProj; var centerMarker = null; var radiusMarker = null; var circleLine; var map; var circles = Array(); var marker_counter = 0; var markers = Array(); var currentTime = new Date(); var uniqueTime = currentTime.getTime(); function move_cursor() { var clatlong = CHtoWorld(document.recherche.xpt.value, document.recherche.ypt.value); document.recherche.latpt.value = clatlong[0]; document.recherche.longpt.value = clatlong[1]; markerD2.setPosition(clatlong); } function initialize() { map = new google.maps.Map( /* instanciation d'une nouvelle carte*/ document.getElementById('map_canvas'), { zoom: 9, streetViewControl: false, // désactivation du contrôle streetview zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE }, panControl: false, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU }, mapTypeId: google.maps.MapTypeId.SATELLITE }); var kml = new google.maps.KmlLayer('http://www.crealp.ch/wolga/communes_vs.php?t='+uniqueTime, {suppressInfoWindows: true, preserveViewport: true}); var lastPoint; mouseMoveHandler = google.maps.event.addListener(map, 'mousemove', function(event) { lastPoint = event.latLng; }); kml.setMap(map); } function initialize_cursor() { map = new google.maps.Map( /* instanciation d'une nouvelle carte*/ document.getElementById('map_canvas'), { center: new google.maps.LatLng(latpt,longpt), zoom: 9, streetViewControl: false, // désactivation du contrôle streetview zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE }, panControl: false, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU }, mapTypeId: google.maps.MapTypeId.SATELLITE }); var kml = new google.maps.KmlLayer('http://www.crealp.ch/wolga/communes_vs.php?t='+uniqueTime, {suppressInfoWindows: true, preserveViewport: true}); var iconrouge_all = { url: "img/symbol/rouge_all.png", origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(9, 9) }; var lastPoint; mouseMoveHandler = google.maps.event.addListener(map, 'mousemove', function(event) { lastPoint = event.latLng; }); // Symbole de pointage à déplacer var point = new google.maps.LatLng(latpt,longpt); var info = 'Déplacer ce curseur qui constitue le centre de la zone de recherche'; var markerD2 = new google.maps.Marker({ position: point, icon: iconrouge_all, draggable: true, visible: true, title: info, map: map }); // VOIR EXEMPLE SUIVANT : http://www.benknowscode.com/2013/06/using-google-maps-drawing-manager-to_30.html // Ajout d'un cercle, rectangle ou polygone editables sur la carte google.maps.event.addListener(markerD2, 'drag', function(event) { var coords = LatToCHCoords(markerD2.getPosition().lat().toFixed(14), markerD2.getPosition().lng().toFixed(14)); document.recherche.xpt.value = Math.round(coords[0]); document.recherche.ypt.value = Math.round(coords[1]); document.recherche.latpt.value = markerD2.getPosition().lat().toFixed(14); document.recherche.longpt.value = markerD2.getPosition().lng().toFixed(14); }); // ajout d'un cercle et liaison (bind) au marker var circle = new google.maps.Circle({ map: map, editable: false, draggable: false, radius: Math.round(document.recherche.distpt.value), fillColor: '#FF0000', fillOpacity: 0.1, strokeColor: '#FF0000', strokeWeight: 2 }); circle.bindTo('center', markerD2, 'position'); google.maps.event.addListener(circle, 'radius_changed', function() { document.recherche.distpt.value = Math.round(this.radius); }); circleOverListner = google.maps.event.addDomListener(circle, 'mouseover', function() { this.setEditable(true); }); circleOutListner = google.maps.event.addDomListener(circle, 'mouseout', function() { this.setEditable(false); }); kml.setMap(map); } function initialize_interactive() { map = new google.maps.Map( /* instanciation d'une nouvelle carte*/ document.getElementById('map_canvas'), { center: new google.maps.LatLng(46.25,7.6), zoom: 9, draggableCursor: 'crosshair', streetViewControl: false, // désactivation du contrôle streetview zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE }, panControl: false, mapTypeControl: true, mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU }, mapTypeId: google.maps.MapTypeId.SATELLITE }); var kml = new google.maps.KmlLayer('http://www.crealp.ch/wolga/communes_vs.php?t='+uniqueTime, {suppressInfoWindows: true, preserveViewport: true}); kml.setMap(map); var iconrouge_all = { url: "img/symbol/rouge_all.png", origin : new google.maps.Point(0, 0), anchor: new google.maps.Point(9, 9) }; var coords = LatToCHCoords(46.25,7.6); document.forms['add_site_form'].elements['site_X_coord'].value = Math.round(coords[0]); document.forms['add_site_form'].elements['site_Y_coord'].value = Math.round(coords[1]); document.forms['add_site_form'].elements['site_lat'].value = 46.25; document.forms['add_site_form'].elements['site_long'].value = 7.6; var lastPoint; mouseMoveHandler = google.maps.event.addListener(map, 'mousemove', function(event) { lastPoint = event.latLng; //console.log(lastPoint.lat() + ' / ' +lastPoint.lng()); }); // Symbole de pointage à déplacer var point = new google.maps.LatLng(46.25,7.6); var info = 'Déplacer ce curseur qui constitue le centre de la zone de recherche'; var markerD2 = new google.maps.Marker({ position: point, icon: iconrouge_all, draggable: true, visible: true, title: info, map: map }); // VOIR EXEMPLE SUIVANT : http://www.benknowscode.com/2013/06/using-google-maps-drawing-manager-to_30.html // Ajout d'un cercle, rectangle ou polygone editables sur la carte google.maps.event.addListener(markerD2, 'drag', function(event) { var coords = LatToCHCoords(markerD2.getPosition().lat().toFixed(14), markerD2.getPosition().lng().toFixed(14)); document.forms['add_site_form'].elements['site_X_coord'].value = Math.round(coords[0]); document.forms['add_site_form'].elements['site_Y_coord'].value = Math.round(coords[1]); document.forms['add_site_form'].elements['site_lat'].value = markerD2.getPosition().lat().toFixed(14); document.forms['add_site_form'].elements['site_long'].value = markerD2.getPosition().lng().toFixed(14); get_location(Math.round(coords[0]), Math.round(coords[1])); }); google.maps.event.addListener(map, 'click', function() { new_pos = lastPoint; markerD2.setPosition(new_pos); var coords = LatToCHCoords(markerD2.getPosition().lat().toFixed(14), markerD2.getPosition().lng().toFixed(14)); document.forms['add_site_form'].elements['site_X_coord'].value = Math.round(coords[0]); document.forms['add_site_form'].elements['site_Y_coord'].value = Math.round(coords[1]); document.forms['add_site_form'].elements['site_lat'].value = markerD2.getPosition().lat().toFixed(14); document.forms['add_site_form'].elements['site_long'].value = markerD2.getPosition().lng().toFixed(14); get_location(Math.round(coords[0]), Math.round(coords[1])); }); }