203,6 → 203,14 |
function initialiserCarte() { |
geocoder = new google.maps.Geocoder(); |
latLng = new google.maps.LatLng(43.577, 3.455); |
map = new google.maps.Map(document.getElementById('gg-map-carte'), { |
zoom: 9, |
mapTypeId: google.maps.MapTypeId.HYBRID, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.TERRAIN]} |
}); |
|
// Ajout de la couche OSM à la carte |
osmMapType = new google.maps.ImageMapType({ |
getTileUrl: function(coord, zoom) { |
return "http://tile.openstreetmap.org/" + |
214,18 → 222,13 |
name: "OSM", |
maxZoom: 19 |
}); |
map = new google.maps.Map(document.getElementById('gg-map-carte'), { |
zoom: 9, |
center: latLng, |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
mapTypeControlOptions: { |
mapTypeIds: ['OSM', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.TERRAIN], |
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU} |
}); |
|
map.mapTypes.set('OSM', osmMapType); |
map.setMapTypeId(google.maps.MapTypeId.HYBRID); |
|
// Ajout des limites de communes |
ctaLayer = new google.maps.KmlLayer('http://www.tela-botanica.org/commun/google/map/3/kmz/communes/34.kmz', {preserveViewport: true}); |
ctaLayer.setMap(map); |
|
// Définition du marqueur |
marker = new google.maps.Marker({ |
position: latLng, |
title: 'Ma station', |
232,12 → 235,23 |
map: map, |
draggable: true |
}); |
deplacerMarker(latLng); |
|
// Update current position info. |
mettreAJourMarkerPosition(latLng); |
geocoderPosition(latLng); |
// Tentative de géolocalisation |
if(navigator.geolocation) { // Try W3C Geolocation (Preferred) |
navigator.geolocation.getCurrentPosition(function(position) { |
(DEBUG) ? console.log("Géolocalisation OK.") : ''; |
latLng = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); |
deplacerMarker(latLng); |
map.setCenter(latLng); |
}, function() { |
(DEBUG) ? console.log("Géolocalisation échouée.") : ''; |
}); |
} else { //Browser doesn't support Geolocation |
(DEBUG) ? console.log("Navigateur ne supportant pas la géolocalisation. Localisation par défaut.") : ''; |
} |
|
// Add dragging event listeners. |
// Add des évènements concernant le marqueur |
google.maps.event.addListener(marker, 'dragstart', function() { |
mettreAJourMarkerAdresse('Marqueur de station début du déplacement...'); |
}); |
258,6 → 272,15 |
}); |
} |
|
function deplacerMarker(latLon) { |
if (marker != undefined) { |
marker.setPosition(latLon); |
mettreAJourMarkerStatut('Marqueur de station déplacé (clic).'); |
mettreAJourMarkerPosition(marker.getPosition()); |
geocoderPosition(marker.getPosition()); |
} |
} |
|
function geocoderPosition(pos) { |
if (geocoder != undefined) { |
geocoder.geocode({ |
301,11 → 324,3 |
document.getElementById('marqueur-adresse').innerHTML = str; |
} |
|
function deplacerMarker(latLon) { |
if (marker != undefined) { |
marker.setPosition(latLon); |
mettreAJourMarkerStatut('Marqueur de station déplacé (clic).'); |
mettreAJourMarkerPosition(marker.getPosition()); |
geocoderPosition(marker.getPosition()); |
} |
} |