Visitors end up seeing the entire world on the map when GeoCoordinates are not available.
There are two ways to combat this,
Either position map (calculate longitude) based on the timezone from system date,
The entire map is still seen, but the map is positioned with the visitors location at the center.
Below is the map show to a visitor from northern South America, instead of all continents.
Here is how to do it,
latitude = 51.50019435946635; // Latitude coordinate for GMT
var d = new Date();
longitude = 7 * -((d.getTimezoneOffset() / 60) * 2);
Use the free webservice provided by IP INFO DB.
This returns a XML file with sufficient data such as Location Name, Latitude, Longitude, etc.. However, With the best case scenario, this might only fetch you the city level geographical location, since this might just be the ISP’s location, which is of no use.
Try Out : http://ipinfodb.com/ip_query.php
7 replies on “Maps : Zoom into appropriate location”
Thanks for article. Everytime like to read you.
blog.immanuelnoel.com – da best. Keep it going!
Very nice blog! Bookmarked 🙂
It is useful to try everything in practice anyway and I like that here it’s always possible to find something new. 🙂
You have really great taste on catch article titles, even when you are not interested in this topic you push to read it
Visitors end up seeing the entire world on the map when GeoCoordinates are not available…..
Thanks for the info, now I will not tolerate such a mistake ….
Very shorts, simple and easy to understand.