SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Google Map

  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Google Map

    Hai guys,

    I have a question.

    In google map, say i want to display the map of "New York" city, do i need to provided the coordinates or i need to provide the city name in google api ?

    Last edited by afridy; Aug 4, 2008 at 23:11.

  2. #2
    SitePoint Member
    Join Date
    Aug 2008
    Location
    Ohio
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to use Long/Lat coords to target the city of your choosing with the setCenter() call in the Initialize function (I think the long/lat coords will be the center of your map). EX:

    Code:
    function initialize() {
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map_canvas"));
            map.setCenter(new GLatLng(37.4419, -122.1419), 13);
          }
        }
    GLatLng(x, y), where x and y are the coordinates you specify. The other parameter is a zoom parameter.

    Then you can just display the map to the screen with:

    Code:
    <body onload="initialize()" onunload="GUnload()">
        <div id="map_canvas" style="width: 500px; height: 300px"></div>
      </body>
    Hope this helps, let me know.

    Zack

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Zack,
    then we really need to find the coordinates by ourselves right.
    there is no way to send only the name of the city and displayed in the map right?.

    btw, tx for the example

  4. #4
    SitePoint Member
    Join Date
    Aug 2008
    Location
    Ohio
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've searched the Google Maps API reference page and the only thing I can find that sets the maps center of interest is passing an object of GetLatLng type to the setCenter() function.

    You can enter a city name into Google Maps however and get a result you want, which leads me to believe there are functions we do not have access to which tie into some geocode database linking cities with their long/lat coordinates.

    However I think us regular people are stuck with coords. If you are worried about finding coordinates there are some places you can find coordinates however.

    I'm going to continue to search though, maybe I've overlooked, but the only way I've seen is through GetLatLng, which requires coordinates.

    http://nationalatlas.gov/natlas/Natlasstart.asp
    http://www.Tageo.com

  5. #5
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Zack,
    thanks for the researches. this one look like prety good http://www.Tageo.com
    in case if really need to feed the coordinates.

  6. #6
    SitePoint Zealot Rexibit's Avatar
    Join Date
    Jul 2008
    Location
    United States
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Google maps is generally to show a "place" or "business." With this, you usually have a listing that you specifically want to point out.

    I would suggest either picking a general point in NY to show, or contact Google and ask for the work-around.
    Rexibit Web Services
    Don't just build it - CSS it

  7. #7
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    listing you mean rexibit,
    we need a db with all the cities and it coordinates?

  8. #8
    SitePoint Zealot Rexibit's Avatar
    Join Date
    Jul 2008
    Location
    United States
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, you are looking to have a means of displaying a map of an area dynamically on your site?

    With the currently available functions you would need coordinates. What I meant was that a business's website for example would generally have a fixed physical location. The Google map is there to help people find them. So, either you should pick a general place or contact Google to ask how to tweak the Google map to fit your needs.
    Rexibit Web Services
    Don't just build it - CSS it

  9. #9
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Montreal
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look at the code on this page:

    http://code.google.com/apis/maps/documentation/examples/geocoding-simple.html



    There is a javascript function in it that finds the coordinates with just the address.

  10. #10
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by digadesign View Post
    Look at the code on this page:

    http://code.google.com/apis/maps/documentation/examples/geocoding-simple.html



    There is a javascript function in it that finds the coordinates with just the address.
    Book Marked
    nice one.

  11. #11
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    All the map references I use are database driven (Storing co-ords on a street level basis for page view purposes).

    But if you need a quick reference here's one I found on another site that I converted for my needs, gives me a quick and dirty lat-long match

    http://www.anelegantchaos.org/getmap...C+Dunfermline#


Bookmarks

Posting Permissions

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