Witam
Mam mały problem z google maps. Potrzebuje zczytać latitude i longitude do inputa. Wszystko jest ok do momentu kiedy postawie markera z opcją draggable.
Chodzi o to aby po przesunięciu markera w inne miejsce , w inpucie pojawily sie latituda i longituda (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif)
oto kod:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Google Maps JavaScript API Example: Tile Detector
</title> <script src="http://maps.google.com/maps?file=api&v=2" type="text/javascript"></script> <script type="text/javascript"> function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.88, -122.442626), 10);
var marker = new GMarker(new GLatLng(37.88,-122.442626),{draggable:true});
map.addOverlay(marker);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
GEvent.addListener(marker,"click", function(overlay,latlng) {
if (overlay) {
// ignore if we click on the info window
return;
}
var tileCoordinate = new GPoint();
var tilePoint = new GPoint();
var currentProjection = G_NORMAL_MAP.getProjection();
tilePoint = currentProjection.fromLatLngToPixel(latlng, map.getZoom());
// var myHtml = "Latitude: " + latlng.lat() + "
<br/>Longitude: " + latlng.lng() +
// "
<br/>The Tile Coordinate is:
<br/> x: " + tileCoordinate.x +
//"
<br/> y: " + tileCoordinate.y + "
<br/> at zoom level " + map.getZoom();
//map.openInfoWindow(latlng, myHtml);
var myHtml = latlng.lat() + " , " +latlng.lng();
document.getElementById('message').innerHTML = myHtml;
});
}
}
<body onload="initialize()" onunload="GUnload()"> <div id="map_canvas" style="width: 500px; height: 300px">Loading ....
</div>
Prubowałem zamienić
GEvent.addListener(marker,"click", function(overlay,latlng) {
na
GEvent.addListener(marker,"dragend", function(overlay,latlng) {
niestety nic (IMG:
http://forum.php.pl/style_emoticons/default/sad.gif)
Proszę o pomoc
Pozdrawiam eska