Ho trovato questo script che dovrebbe fare al caso mio... perchè su google maps va benissimo....
ma invece io non riesco a farlo funzionare...
in sostanza a me serve cliccare su un punto della mappa ed ottenere le coordinate...
come in questo esempio...
Codice PHP:
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map,"click", function(overlay,latlng) {
if (latlng) {
var myHtml = "The GLatLng value is: " + map.fromLatLngToDivPixel(latlng) + " at zoom level " + map.getZoom();
map.openInfoWindow(latlng, myHtml);
}
});
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
}
}​
ma con le coordinate geografiche e non di pixel
in ogni caso ecco lo script che non riesco ad integrare... evidentemente non so come si usa... mi aiutate?
Codice PHP:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
title="GPS Location"
description="Used to find GPS locations (Latitude & Longitude) on a Google map."
author="Jeff Grigg"
author_email="jeffgrigg@charter.net"
author_link="http://jeffgrigg.wordpress.com/"
screenshot="http://gpsmaplet.googlecode.com/files/Screen%20Print.PNG"
thumbnail="http://gpsmaplet.googlecode.com/files/Icon.PNG"
height="200">
<Require feature="sharedmap"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<h2>GPS Location</h2>
Click on the map to show the GPS location (Latitude & Longitude) of that location.</p>
Many thanks to [url="http://thomas.duebendorfer.ch/"]Thomas Duebendorfer[/url] for the Position Finder Maplet, which inspired this Maplet.</p>
<script>
var gMap2 = new GMap2();
function mapClick(gMarker, gLatLng) {
if (gMarker) {
displayMarkerPosition(gMarker);
} else if (gLatLng) {
createLocationMarker(gLatLng);
}
}
function createLocationMarker(gLatLng) {
var gMarker = new GMarker(gLatLng, {draggable: true, bouncy: true});
gMap2.addOverlay(gMarker);
displayMarkerPosition(gMarker);
GEvent.addListener(gMarker, "dragstart", closeMapInfoWindow);
GEvent.addListener(gMarker, "dragend", function() {
displayMarkerPosition(gMarker);
});
}
function closeMapInfoWindow() {
gMap2.closeInfoWindow();
}
function displayMarkerPosition(gMarker) {
GAsync(gMarker, 'getPoint', gMap2, 'getBounds', 'getSize', function(gLatLng, gLatLngBounds, gSize) {
gMarker.openInfoWindowHtml(gpsString(gLatLng, gLatLngBounds, gSize));
});
}
function gpsString(gLatLng, gLatLngBounds, gSize) {
var ne = gLatLngBounds.getNorthEast();
var sw = gLatLngBounds.getSouthWest();
var degreesPerPixel = (ne.lat() - sw.lat()) / gSize.height;
var goodDigits = Math.ceil(- Math.log(degreesPerPixel) / Math.log(10))
var roundedLatLng = roundGLatLng(gLatLng, goodDigits);
return "GPS: " + roundedLatLng.lat() + ", " + roundedLatLng.lng();
}
function roundGLatLng(gLatLng, goodDigits) {
return new GLatLng(roundNumber(gLatLng.lat(), goodDigits), roundNumber(gLatLng.lng(), goodDigits));
}
function roundNumber(number, goodDigits) {
var power = Math.pow(10, Math.ceil(goodDigits));
return Math.round(number * power) / power;
}
GEvent.addListener(gMap2, "click", mapClick);
</script>
]]></Content>
</Module>