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:
Produces this Map:
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
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"
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)---------------------------------------------------------------
Comment