...

View Full Version : Help with Google map script



websailor
03-06-2009, 01:24 PM
Hello,

I found a script that locate longitud,latitud on Google map as showen below:


<script language="javascript">

function checkear(){
procesar_mapa(document.getElementById("IP").value);
}
function procesar_mapa(VALORIP) {
var request = GXmlHttp.create();
request.open('GET', '/data.php?IP=' + VALORIP, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {

var xmlDoc = request.responseXML;
var markers = xmlDoc.documentElement.getElementsByTagName("marker");

Vlong = markers[0].getAttribute("lng");
Vlat = markers[0].getAttribute("lat");
Vcity = markers[0].getAttribute("city");
Vcountry = markers[0].getAttribute("country");
Vhost = markers[0].getAttribute("host");
Vip = markers[0].getAttribute("ip");
Vcode = markers[0].getAttribute("code");
Vurl = "http://geoiptool.com?IP=" + markers[0].getAttribute("ip");

createmap(Vlong,Vlat,Vcity,Vcountry);

ho = document.getElementById("url");
ho = document.getElementById("host");
pa = document.getElementById("pais");
oip = document.getElementById("ipz");
ourl = document.getElementById("urlx");
oimg = document.getElementById("imgx");

ho.innerHTML = Vhost;
pa.innerHTML = Vcountry;
oip.innerHTML = Vip;
ourl.href = Vurl;
oimg.src = '/flags/' + Vcode.toLowerCase() + '.gif';

}
}
request.send(null);
}

function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {

});
return marker;
}

function createmap(longitud,latitud,ciudad,pais) {
if (GBrowserIsCompatible()) {
var map = new GMap(document.getElementById("map"));
map.addControl(new GOverviewMapControl());
map.addControl(new GSmallMapControl());
map.enableDoubleClickZoom();
map.enableScrollWheelZoom();
map.addControl(new GMapTypeControl());
map.addControl(new GSmallMapControl());
map.setMapType(G_SATELLITE_MAP);
map.centerAndZoom(new GPoint(longitud, latitud), 5);
var point = new GPoint(longitud, latitud);
var marker = createMarker(point, ciudad+" , "+pais);
map.addOverlay(marker);
}
}

function trapEnter(e, enterFunction){
if (!e) e = window.event;
if (e.keyCode == 13){
e.cancelBubble = true;
if (e.returnValue) e.returnValue = false;
if (e.stopPropagation) e.stopPropagation();
if (enterFunction) eval(enterFunction);
return false;
} else {
return true;
}
}

</script>

</head>

<body onLoad='createmap("23.7304","37.9753","Athen","Italy")'>


So what should i change in the onLoad to let it work for my web visiters,

I changed : onLoad='createmap("23.7304","37.9753","Athen","Italy")'>

To: onLoad='createmap("map")'>

And to: onLoad="createmap('map')">

I tried alot but it dos not work !

Any help please....

tomws
03-06-2009, 02:12 PM
I'm not sure what this has to do with DOM and JSON. It would be better placed in the plain old Javascript forum maybe.

The function createmap() takes the four arguments longitude, latitude, city, and nation. Your single argument of "map" wouldn't work for any of those.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum