Results 1 to 18 of 18

Thread: How to map multiple addresses in Google Maps.

  1. #1

    Default How to map multiple addresses in Google Maps.

    Here is the code needed to map out multiple addresses through Google Maps. These are only static maps, however I do have the code to generate kml files which can be used through Maps or Google Earth.

    To use this code you must have a Maps API Key found here.

    This Example:
    Code:
    ?static_map("106 S. Main Street, North East, MD","241 Market Street Charlestown MD 21914","64 South Main Street Port Deposit, Maryland 21904","1 E Main St Rising Sun, MD 21911","107 Chesapeake Blvd Elkton, MD 21921-6313, US")
    = "http://maps.google.com/staticmap?&size=512x512&markers=39.600076,-75.942774|39.572971,-75.975116|39.600979,-76.111402|39.698069,-76.062902|39.605745,-75.787264|&key=ENTER KEY HERE"
    Produces this Map:



    This work is licensed under a Creative Commons Attribution 3.0 Unported License.

    Code:
    Index of Functions
    ------------------
       1:  accuracy
       2:  geocode_xml
       3:  static_map
         
         
         
    Function Name (   1):  accuracy
    --------------------------------------------------------------------------------
    'Date Created: 15-Dec-2007 04:54:39 PM
    'Last Updated: 21-Dec-2007 03:12:25 AM
    'Created By  : GreenJEans
    'Updated By  : GreenJEans
    'This work is licensed under a Creative Commons Attribution 3.0 Unported License
    FUNCTION accuracy AS A (value AS C )
        dim result as P
        result.zoom = "10000"
        
        if value = "0" then
            result.body = "Unknown location."
            result.zoom = "12874752"
            end if
        if value = "1" then
            result.body = "Country level accuracy."
            result.zoom = "4023360"
            end if
        if value = "2" then
            result.body = "Region (state, province, prefecture, etc.) level accuracy."
            result.zoom = "402336"
            end if
        if value = "3" then
            result.body = "Sub-region (county, municipality, etc.) level accuracy."
            result.zoom = "48280"
            end if
        if value = "4" then
            result.body = "Town (city, village) level accuracy."
            result.zoom = "16093"
            end if
        if value = "5" then
            result.body = "Post code (zip code) level accuracy."
            result.zoom = "16093"
            end if
        if value = "6" then
            result.body = "Street level accuracy."
            result.zoom = ""
            end if        
        if value = "7" then
            result.body = "Intersection level accuracy."
            result.zoom = ""
            end if
        if value = "8" then
            result.body = "Address level accuracy."
            result.zoom = ""
            end if
    accuracy = result
    END FUNCTION    
    End Function (   1)---------------------------------------------------------------
      
      
    Function Name (   2):  geocode_xml
    --------------------------------------------------------------------------------
    'Date Created: 11-Dec-2007 01:57:08 AM
    'Last Updated: 17-Aug-2008 05:01:30 PM
    'Created By  : GreenJEans
    'Updated By  : GreenJeans
    'This work is licensed under a Creative Commons Attribution 3.0 Unported License
    FUNCTION geocode_xml AS A (address AS C )
        dim x as P
        dim i as N
        delete response
        dim response as A
        i=0
        key ="ENTER YOUR KEY HERE"
        url = "http://maps.google.com/maps/geo?q="+urlencode(Address)+"&output=xml&key="+key
        response = http_post(url,"","",80,2500,.f.)
        x.body = response.body
        x.code = extract_string(response.body,"<code>","</code>")
                    x.error = "Invalid Location..."
                    x.Request = extract_string(response.body,"<request>","</request>")
                    x.Name = extract_string(response.body,"<Name>","</Name>")
                    a = accuracy("0")
                    x.Accuracy = a.body
                    x.Zoom = a.zoom
                    x.Country = ""
                    x.AdministrativeArea = " "
                    x.Locality = ""
                    x.PostalCode = ""
                    x.Point = ""
                    x.has_gps = .f.
                    x.latitude = ""
                    x.longitude = ""
                    x.Time = now()
                    x.Address=""
                    x.marker=""
    if x.code = "200" then
                x.Request = extract_string(response.body,"<request>","</request>")
                x.Address = extract_string(response.body,"<address>","</address>")
                a = accuracy(extract_string(response.body,"Accuracy=\"","\" xmlns"))
                x.Accuracy = a.body
                x.Zoom = a.zoom
                x.Country = extract_string(response.body,"<CountryNameCode>","</CountryNameCode>")    
                x.AdministrativeArea = extract_string(response.body,"<AdministrativeAreaName>","</AdministrativeAreaName>")
                x.Locality = extract_string(response.body,"<LocalityName>","</LocalityName>")
                x.PostalCode = extract_string(response.body,"<PostalCodeNumber>","</PostalCodeNumber>")
                x.Point = extract_string(response.body,"<coordinates>","</coordinates>")
                x.has_gps = .t.
                x.latitude = word(x.Point,2,",")
                x.longitude = word(x.Point,1,",")
                x.Time = now()
                x.marker = word(x.Point,2,",")+","+word(x.Point,1,",")
                end if            
    
    
              
    geocode_xml = x
    END FUNCTION    
    End Function (   2)---------------------------------------------------------------
      
      
    Function Name (   3):  static_map
    --------------------------------------------------------------------------------
    'Date Created: 17-Aug-2008 05:01:32 PM
    'Last Updated: 17-Aug-2008 05:01:32 PM
    'Created By  : GreenJeans
    'Updated By  : GreenJeans
    'This work is licensed under a Creative Commons Attribution 3.0 Unported License
    FUNCTION static_map AS C (Address1 as c, Address2="", Address3="", Address4="", Address5="",height="512", length="512")
        Dim a1 as p
        Dim a2 as p
        Dim a3 as p
        Dim a4 as p
        Dim a5 as p
        url =""
        key ="ENTER YOUR KEY HERE"
        url = "http://maps.google.com/staticmap?&size=512x512"
        url = url+"&markers="    
        
        a1=geocode_xml(Address1)
        a2=geocode_xml(Address2)
        a3=geocode_xml(Address3)
        a4=geocode_xml(Address4)
        a5=geocode_xml(Address5)
        
        url = url+a1.marker+"|"+a2.marker+"|"+a3.marker+"|"+a4.marker+"|"+a5.marker+"|&key="+key
        
        static_map = url
    END FUNCTION  
    End Function (   3)---------------------------------------------------------------

  2. #2
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,697

    Default Re: How to map multiple addresses in Google Maps.

    Hi James,

    I think there is a problem with your url: http://maps.google.com/staticmap?&si...vbTagyDPNmpLEw
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  3. #3

    Default Re: How to map multiple addresses in Google Maps.

    When i clicked on your link it failed...when i clicked on mine it worked. I think its something on google's end.

    I utilized the api from google. I dont know what went wrong. However static maps are of little use. I have code that writes KML for the addresses. I am still working on a way to take the new google earth plugin for internet browsers and placing it inside alpha.
    Here is the image...
    Attached Images Attached Images

  4. #4
    Member
    Real Name
    Mitch Thompson
    Join Date
    Apr 2009
    Posts
    1

    Default Re: How to map multiple addresses in Google Maps.

    Hi GreenJeans,

    I know it's been awhile since you have seen this post but I have to tell you that your syntax for multiple lat/lon in a Google Maps URL is great and quite unique on the Internet. I have been searching the 'net' for days looking for just this syntax but I kept getting dragged into other peoples' pages of code and commentary regarding javascript. I know it only produces a staticmap but that is really all I needed for my app.

    I have to ask: is there a way to add marker descriptions to the multiple lat/lon's (addresses) on the submitted Google Maps URL? I know... somethng about cake and eating it too....but I have to ask. If the answer is no, then 'Thanks' just the same (and now I scurry back to the 'code cave' quite happy with your staticmap solution) :D

  5. #5

    Default Re: How to map multiple addresses in Google Maps.

    Hey there Junocat,

    Ironically it has not been very long since I have seen this code I keep up with things on a regular basis. To answer your question straight up no the static maps do not allow for marker descriptions. This is not any fault of mine...the issue lies with Google. The static maps allow for one character identification inside each marker.

    http://code.google.com/apis/maps/doc...kerDescriptors

    This link will take you to the marker requirements in the map api itself.

    An alternate solution that I might suggest for you is using KML. Google provides an in-browser Google plug in. They offer both the Maps and the Google Earth for KML.

    All the source code I have posted online is really just an aggregate for data. If you are interested in code that is able to generate KML files let me know.

  6. #6
    Member ColinJD's Avatar
    Real Name
    Colin Davies
    Join Date
    Jun 2006
    Location
    NZ
    Posts
    457

    Default Re: How to map multiple addresses in Google Maps.

    Hi Mr GreenJeans,
    -
    I play with google maps a lot at the moment, but I can't see why I should use KML files. Can you enlighten me with respect to Alpha Five. Thanks

  7. #7

    Default Re: How to map multiple addresses in Google Maps.

    Depending on usage both have their own strenghts. If you are in need of a simple map image then use the static map code. If you are building a app that requires pliable maps then using the google maps function in A5v9 will be the best option.

    However IMHO KML provides the best medium for mapping any data. You can add descriptions, images, among many other features. This format also makes it easy to share the map among users. You can utilize the NetworkLinks comand built into KML to create maps that update on a schedule you decide. So for example you can host the data, send a client a NetworkLink and they can see what you see...that way if you update the map they see it on the next time they open it.

    There are many features to KML that I think make it the more robust choice. Perhaps you might agree?

  8. #8
    Member ColinJD's Avatar
    Real Name
    Colin Davies
    Join Date
    Jun 2006
    Location
    NZ
    Posts
    457

    Default Re: How to map multiple addresses in Google Maps.

    Ok,
    Thanks for trying to explain it to me. However I'm thinking now I'd better get my hands dirty with some KML to really have an idea of what's happening.
    -
    I'm actually working with A5 Web apps, FYI the areas of the Maps API, I'm using are Custom Markers, Info Windows, Streetview, Geocoding (like you), Polygons Polylines, and some Tiles. So if you ever need any assist in those areas please sing out. This weekend I'll have a dive into KML.

  9. #9

    Default Re: How to map multiple addresses in Google Maps.

    If you are familiar with the Google Maps Api then KML is just an extension of that...

    I would recomend brushing up on XML skills and read the documentation that Google provides for the KML. When combined with alpha the uses are amazing...I wrote a app that would take a list of addresses and geocode them, then categorize them, and finally write the KML for the map automatically. I geocoded 1800 addresses an hour and with alpha doing the heavy lifting write 2 million characters of code in under 3 minutes flat.

    I wish you luck...and if you have any questions please just let me know.

  10. #10
    "Certified" Alphaholic Charles Hoens's Avatar
    Real Name
    Charles Hoens
    Join Date
    Sep 2000
    Location
    Princeton, NJ
    Posts
    1,048

    Default Re: How to map multiple addresses in Google Maps.

    I was reading your thread. I wanted to place a map of the state of New Jersey on my website containing pins at various locations I would extract from my A5 dbf. How do I go about this or where can I read up on how to accomplish this?

    Thanks,

    Charlie

  11. #11
    Member ColinJD's Avatar
    Real Name
    Colin Davies
    Join Date
    Jun 2006
    Location
    NZ
    Posts
    457

    Default Re: How to map multiple addresses in Google Maps.

    Charlie , unsure whether you are addressing myself or MrGreenJeans.
    Anyhow,
    First place to have a read is http://code.google.com/apis/maps/doc...reference.html.
    and grab a google maps API key while you are there.
    There are multiple ways of acomplishing this, what I suggest is what works for me but otherways are possible.
    On the client||browser side everything is in JavaScript. So If you see a site with something you like like just checkout its html/source code.
    -
    First Geocoding, yes you can put all your addresses in as physical street addresses, But I suggest in your dbf you create a mini geocache of lattitudes and longitudes.
    -
    on your webpage, have it initiate and center a map in javascript,
    next call an AJAX routine ,
    then from the .AJAX.a5w page, it opens and iterates a your dbf, for the lat lngs stored there,
    for each lat lng, send them to a function on your maps page,
    Thus you need a javascript function on your maps page that processes the lat, lngs and creates a marker.
    - If you want this marker can be a simple colored pin or a custom marker||icon , and if also want you can set the marker up to have infowindow txt.

    Hope that gives you an idea, but there are other ways to achieve this, I guess it really depends on your requirements.

  12. #12

    Default Re: How to map multiple addresses in Google Maps.

    As Colin stated there is many different ways to accomplish this. Perhaps you could describe what you would like your end goal to be? Are you interested in static map? Or an interactive map?

    If you do not wish to post these details perhaps you could message me...I should be able to guide you in the right direction.

    I would also be willing to consult with you in the design of your solution. Perhaps I would be able to code something for you specifically.

  13. #13
    Member
    Real Name
    susheel kumar
    Join Date
    Mar 2010
    Posts
    3

    Default Re: How to map multiple addresses in Google Maps.

    The below is an script which can placed multiple locations on google map


    <script type="text/javascript">

    function initialize() {
    if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(26.4984667, 80.3047708), 13);


    map.addOverlay(new GMarker(new GLatLng(26.4949724, 80.2830029)));
    map.addOverlay(new GMarker(new GLatLng(26.4984667, 80.3047708)));
    map.addOverlay(new GMarker(new GLatLng(26.5129934, 80.2339049)));
    map.addOverlay(new GMarker(new GLatLng(26.4754982, 80.2864862)));

    }
    }


    </script>
    in case still any prob contact me at susheel1104@gmail.com

  14. #14
    Member
    Real Name
    susheel kumar
    Join Date
    Mar 2010
    Posts
    3

    Default Re: How to map multiple addresses in Google Maps.

    Quote Originally Posted by ColinJD View Post
    Charlie , unsure whether you are addressing myself or MrGreenJeans.
    Anyhow,
    First place to have a read is http://code.google.com/apis/maps/doc...reference.html.
    and grab a google maps API key while you are there.
    There are multiple ways of acomplishing this, what I suggest is what works for me but otherways are possible.
    On the client||browser side everything is in JavaScript. So If you see a site with something you like like just checkout its html/source code.
    -
    First Geocoding, yes you can put all your addresses in as physical street addresses, But I suggest in your dbf you create a mini geocache of lattitudes and longitudes.
    -
    on your webpage, have it initiate and center a map in javascript,
    next call an AJAX routine ,
    then from the .AJAX.a5w page, it opens and iterates a your dbf, for the lat lngs stored there,
    for each lat lng, send them to a function on your maps page,
    Thus you need a javascript function on your maps page that processes the lat, lngs and creates a marker.
    - If you want this marker can be a simple colored pin or a custom marker||icon , and if also want you can set the marker up to have infowindow txt.

    Hope that gives you an idea, but there are other ways to achieve this, I guess it really depends on your requirements.

  15. #15
    Member
    Real Name
    susheel kumar
    Join Date
    Mar 2010
    Posts
    3

    Default Re: How to map multiple addresses in Google Maps.

    Quote Originally Posted by Keith Hubert View Post
    Hi James,

    I think there is a problem with your url: http://maps.google.com/staticmap?&si...vbTagyDPNmpLEw
    The below is the script for which show multiple location on google map

    <script type="text/javascript">

    function initialize() {
    if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(26.4984667, 80.3047708), 13);


    map.addOverlay(new GMarker(new GLatLng(26.4949724, 80.2830029)));
    map.addOverlay(new GMarker(new GLatLng(26.4984667, 80.3047708)));
    map.addOverlay(new GMarker(new GLatLng(26.5129934, 80.2339049)));
    map.addOverlay(new GMarker(new GLatLng(26.4754982, 80.2864862)));

    }
    }


    </script>
    i

  16. #16
    VAR
    Real Name
    Bill Parker
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    1,544

    Default Re: How to map multiple addresses in Google Maps.

    Thanks GreenJeans. The code works fine without the key when running from a desktop app. Just open the page with sys_open(url).

    Is the key required only if the page is being displayed by my own web site?

    Static is a great first step. I have not tested, but is there a length limit to the url, which would limit the number of points that can be displayed?

    Of course this also makes you want to go dynamic with marker pop-up info.

    Bill.

  17. #17
    Member
    Real Name
    tran minh thien
    Join Date
    May 2012
    Posts
    19

    Default Re: How to map multiple addresses in Google Maps.

    Hi all!
    I'm researching about google map and baidu map in alpha five .V11, and current apply project of China .! I'm have some question.
    1. Are A5 support 'polyline' function in google map?
    2. How to draw 'polyline' dynamic on google map component?
    Please help me!
    Thank all!

  18. #18
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,697

    Default Re: How to map multiple addresses in Google Maps.

    Hi Tran,

    Have a look at the Tutorial Videos here.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

Similar Threads

  1. Here is an Example, Google Maps, Images, GridLinker, Download
    By peteconway in forum Application Server Version 8
    Replies: 25
    Last Post: 05-25-2010, 10:22 AM
  2. revised demo works for both google maps and mapquest
    By crimmelcp in forum Alpha Five Version 9 - Desktop Applications
    Replies: 0
    Last Post: 05-13-2008, 01:48 PM
  3. Map Multiple Addresses and Display in A5?
    By Charlain in forum Alpha Five Version 8
    Replies: 0
    Last Post: 09-19-2007, 11:29 PM
  4. Creating the live Google Maps and UPS tracking example
    By Richard Rabins in forum Announcements
    Replies: 0
    Last Post: 02-15-2007, 03:51 PM
  5. Google Maps and UPS in Alpha Five v8
    By Richard Rabins in forum Announcements
    Replies: 0
    Last Post: 01-26-2007, 03:08 PM

Posting Permissions

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

The Reviews Are In...

It just is revolutionary and reminds me of VB and how it changed the world.
quote Robert Scoble, Scobleizer

...Version 10 is a turning point on how developers will be writing applications for the web
quote Alan Ashendorf, Lets Talk Computers

Alpha Five version 10... this version is really a break-through for web developers.
quote The Wall Street Journal, Digital Network

Our Professional Services Division

Training and Mentoring - Alpha Software's Professional Services division is here to help. We offer mentoring and training services, for those who need guidance or advice building their own applications.

Development Services - Need someone to build your application? We'll get the job done right. We have an in-house team of Alpha Five developers and a network of carefully selected artists, designers and IT professionals ready to handle projects of any size. Read more .

submit a project request

Alpha Five Awards & Press
awards
Products Store Support Services About Cart Site Map Resources Home
© Copyright 2000-2011 Alpha Software, Inc. 70 Blanchard Road Burlington, MA 01803 781.229.4500
more