Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with Google map script

    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....

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •