#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171

    Showing hotels from database on google map


    Hello;

    I need some advice on what would be the best approach to create a google map that shows hotels from my database and put a pin there for each hotel. Something like this (click on the map tab).

    I have address field (which may not be the best option, is it?) or I may have to work with alttude latitude.

    Anyways please let me kno wyour thought it could save me a lot of time before I begin.

    Thanks.
  2. #2
  3. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4124
    start by signing up for a google maps api key

    Then start to read their documentation.

    At some point you'll want to output your list as XML or JSON.

    The rest is AJAX and JavaScript.

    The gmaps api does come with a geocoder to turn addresses into lat/longs to use in the map canvas (a javascript function). However, I had much more success buying a postcode to lat/long database; but that was UK only

    In 2007/2008 I made the first version of this. I haven't worked there since 2008, so it's evolved a little bit (backwards IIMO)

    Comments on this post

    • ManiacDan agrees
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    It's better if you have a latitude / longitude value instead of an address. I believe Google Map's geocoding API has some fairly low limits as far as how many addresses you can geocode per day (I want to say 1000/day although I can't remember exactly), and the cost of an enterprise license, which raises that limit, is pretty high (I think it was 5-figures).
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,688
    Rep Power
    171
    Originally Posted by E-Oreo
    It's better if you have a latitude / longitude value instead of an address. I believe Google Map's geocoding API has some fairly low limits as far as how many addresses you can geocode per day (I want to say 1000/day although I can't remember exactly), and the cost of an enterprise license, which raises that limit, is pretty high (I think it was 5-figures).
    I have already made the columns and everything works the issue is it is not automated enough> I send users to a website to get their alt, lat and put in hotel profiles. I also find address often not stable. They miss spell and put in complete address.
  8. #5
  9. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,136
    Rep Power
    1990
    Googles geocoding API does return a list of addresses that it thinks are what you are looking for if it can't find a direct match, so you can use that list in your app to ask the user which of the returned addresses most closely matches theirs. If there's only one address returned you can use that address straight away but if there's multiple addresses returned, you can ask the user which one is best. Google Maps works the same way, so that's the process that you'd be following.

IMN logo majestic logo threadwatch logo seochat tools logo