tags:

views:

163

answers:

2

Hi,

I am building an accommodation website where users can advertise their room with their address. I want to know if i can use the zipcode to show the exact location in Gmaps which i believe would be much cooler.

I would be very thankful if someone can guide me with simple set of steps to do the same.

thanks in advance!

A: 

Check out the Google Maps API. You can use their geocoding service to convert a full address into coordinates, and then display a marker in a Google Map.

There are libraries available for various languages and platforms.

For PHP, here's an article on Geocoding in PHP (it refers to V2 of the Maps API, though; V3 is the brand-newest.)

Pekka
actually i am new to php, hence i am looking for a script that can take the user address, convert it into latitude and longitude coordinates and then display it in a map.can yu please help me?
Narayanan
Check out the Google Maps API examples, there are step-by-step walkthroughs (no completely finished script but very good to get started). http://code.google.com/apis/maps/documentation/v3/articles.html
Pekka
A: 

You may want to use the Client-side Geocoder in the Google Maps API, as in the following example:

function initialize() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));

    var geocoder = new GClientGeocoder();
    geocoder.setBaseCountryCode("us");

    geocoder.getLatLng(
      "90210",
      function(point) {
        if (point) {
          map.setCenter(point, 13);
          var marker = new GMarker(point);
          map.addOverlay(marker);
        }
      }
    );
  }
}

// ...

<div id="map_canvas" style="width: 500px; height: 300px"></div>

90210 Zip Code

Simply change the "90210" parameter with the zip code of your users.

Daniel Vassallo