1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| function initialize(){
var latLng = new google.maps.LatLng(Mylatitude,Mylongitude);
var map = new google.maps.Map(document.getElementById('mapCanvas'), {
zoom: 15,
center: latLng,
mapTypeControl : false,
streetViewControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var monIconPerso = new google.maps.MarkerImage("../images/marker_0.png");
var marker = new google.maps.Marker({
position: latLng,
icon : monIconPerso,
title: 'Votre position',
map: map,
draggable: true
});
var oldLat = marker.getPosition().lat();
var oldLng = marker.getPosition().lng();
google.maps.event.addListener(marker, "dragend", function(e){
var newLat = marker.getPosition().lat();
var newLng = marker.getPosition().lng();
if(oldLat != newLat || oldLng != newLng){
update_latlng(newLat,newLng);
map.setCenter(latlng);
DrawCircle(5);
}
oldLat = newLat;
oldLng = newLng;
});
function DrawCircle(rd) {
var circleOption = {
strokeColor: circleColor,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: circleColor,
fillOpacity: 0.35,
map: map,
clickable:false,
center: circleCenter,
radius: rd*1000
};
circle = new google.maps.Circle(circleOption);
}
} |
Partager