Note that there are some explanatory texts on larger screens.

plurals
  1. POGeolocation with geo.js
    primarykey
    data
    text
    <p>i need to use geolocation in my website for the banner. I found <a href="http://code.google.com/p/geo-location-javascript/" rel="nofollow">this library</a> which seems to be good: </p> <p>In my page i added this code and the browser shows me the alert to allow to get the position.</p> <p>Code:</p> <pre><code>&lt;script type="text/javascript"&gt; if(geo_position_js.init()){ geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAccuracy:true}); } else{ alert("Functionality not available"); } function success_callback(p) { var latitudine = +p.coords.latitude.toFixed(2); var longitudine = p.coords.longitude.toFixed(2); alert(latitudine+' - '+longitudine); } function error_callback(p) { alert('error='+p.message); } &lt;/script&gt; </code></pre> <p>I can see the alert without problem but i need to get the city to load different banner. How can I do that?</p> <p>I also found this service: <a href="http://www.geonames.org/export/web-services.html#findNearbyPlaceName" rel="nofollow">findNearbyPlaceName</a></p> <p>which allow to find country etc from the latitude and longitude, but how can I use this information? I see that they have a callback with xml or json, i tried to get the url with this code but it is wrong cause browser doesn't show the alert:</p> <pre><code>&lt;script type="text/javascript"&gt; if(geo_position_js.init()){ geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAccuracy:true}); } else{ alert("Functionality not available"); } function success_callback(p) { var latitudine = +p.coords.latitude.toFixed(2); var longitudine = p.coords.longitude.toFixed(2); $.getJSON( 'http://http://api.geonames.org/findNearbyPlaceNameJSON?lat='+latitudine+'&amp;lng='+longitudine, function(data) { alert(data); } ); } function error_callback(p) { alert('error='+p.message); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload