SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Google MAP API or Other!

    I want to use Google MAP API or something alike for searching address,city and zip codes, not for showing a map because the website I am intending to do is for delivering goods for a wide area. The problem is it's so hard and takes long time to gather street names , numbers, and zip codes and they are alot.

    for example:

    <input type="text" name="drop-off" id="drop" style="color:#666666"/>

    the customer will enter like this in the texe field : 10 Abbe......., then autmatically the address appear like this for example 10 abbey st and ect.

    Is it possible to make it with Google MAP API or there are many other things for this issue?


    Thanks in Advance!

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    If you want to find matching addresses, without necessarily displaying them on a map, try looking at the Google Geocode stuff.

    You could, for example, use cURL to fetch JSON encoded data from Google:

    PHP Code:
    $url 'http://maps.google.com/maps/api/geocode/json?sensor=false&language=en&address='.urlencode($_REQUEST['drop-off']);

    $ch curl_init();
    curl_setopt($chCURLOPT_URL$url);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_HEADER0);
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
    curl_setopt($chCURLOPT_MAXREDIRS10);
    curl_setopt($chCURLOPT_CONNECTTIMEOUT5);
    curl_setopt($chCURLOPT_FAILONERRORtrue);
    $response curl_exec($ch);
    curl_close($ch);

    $response json_decode($response);

    if(
    $response->status=='OK') {
        
    // do stuff with the results
    } else {
        
    // tell the user there's an error

    If you want the results to appear directly in the browser, you'll need to set up some Ajax trickery.

  3. #3
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Immerse for the reply. You know, it's kinda complicated for setting it up on a website. If you don't mind give more explaination or guide me to set it up!


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
  •