Maps : Zoom into appropriate location

Written by

in

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

Here is how to do it,

//Language : Javascript

latitude = 51.50019435946635; // Latitude coordinate for GMT
var d = new Date();
longitude = 7 * -((d.getTimezoneOffset() / 60) * 2);

Or,

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

Coping with incompatible browsers

Comments

7 responses to “Maps : Zoom into appropriate location”

  1. SonyaSunny Avatar

    Hi,
    Thanks for article. Everytime like to read you.
    SonyaSunny

  2. Boldy Avatar

    Hello,
    blog.immanuelnoel.com – da best. Keep it going!
    Thanks
    Boldy

  3. Hamburg Escort Avatar

    Very nice blog! Bookmarked 🙂

  4. maverxkzZ Avatar

    It is useful to try everything in practice anyway and I like that here it’s always possible to find something new. 🙂

  5. wjgrun Avatar
    wjgrun

    You have really great taste on catch article titles, even when you are not interested in this topic you push to read it

  6. ????? ????????

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

  7. LongBeach Avatar

    Very shorts, simple and easy to understand.

Leave a Reply

Your email address will not be published. Required fields are marked *