[text]db=addresses.db[/text] [!][/!][closedatabase db=[db]] Google Maps LL Geocode [!] ****** HOUSEKEEPING ******[/!] [showif update add^[submit]] [replace db=[db]&eqIDdatarq=[ID]&append=t&autonumber=ID][formvariables][name]=[url][value][/url]&[/formvariables][/replace] [showif [newrecord]=t][text]ID=[lastautonumber][/text][/showif] [/showif] [!] ****** NEW RECORD ******[/!] [showif [newrec]=t] [/showif] [!] ****** EDIT RECORD ******[/!] [showif [editrec]=t] [search db=[db]&eqIDdatarq=[ID]][founditems] [/founditems][/search] [/showif] [!] ****** GEOCODE ******[/!] [hideif [editrec]=t] [hideif [newrec]=t] [text]findthis=&eqlldatarq=[blank]&IDsort=1&IDtype=num&max=1[/text] [showif [geo]=t][text]findthis=&eqIDdatarq=[ID][/text][/showif] [search db=[db][findthis]] [text]lefttogo=[numfound][/text] [founditems] [text]content=q=[url][address] [zip][/url][/text] [text multi=t]ID=[ID]&thisaddress=[url][address][/url] [zip][/text] [/founditems] [text]found=[numfound][/text][/search] [hideif [found]=0] [text]response=[tcpconnect host=www.google.com][!] [/!][tcpsend]GET /maps?[content] HTTP/1.0[UnURL]%0D%0A%0D%0A[/UnURL][!] [/!]User-Agent: StoreBuilder[UnURL]%0D%0A%0D%0A[/UnURL][!] [/!]Content-type: application/x-www-form-urlencoded[UnURL]%0D%0A%0D%0A[/UnURL][!] [/!]Content-length: [CountChars][content][/CountChars][UnURL]%0D%0A%0D%0A[/UnURL][!] [/!][UnURL]%0D%0A[/UnURL][!] [/!][content][UnURL]%0D%0A[/UnURL][!] [/!][/TCPSend][/tcpconnect][/text] [/hideif] [!] *** found=0 [/!] [/hideif] [!] *** newrec=t[/!] [/hideif] [!] *** editrec=t[/!]

WebDNA Google Map Mashup - GeoCode Manager

This page will let you geocode records as well as edit existing records and create new ones.
  • By default, the page will go through an existing database record by record and generate latitude and longitude coordinates. If Google can't map the address, the page will give you a chance to correct the problem. Once you adjust the address so Google maps it correctly, use the geocode link to generate the coordinates, or simply continue checking for missing geocodes. This is great for adding the necessary values to an existing database. Because you will need to check each address for validity, it goes through them one by one, but you will see that it goes quickly.
  • This sample database (addresses.db) contains a minimum of fields to show you what you need in your own database. The essential fields are Address, Zip, and LL (which expects the latitude and longitude coordinates in the format of "40.187334,-76.182181").
  • You may edit records by clicking the edit link in the balloon text from the map page. Choose a few records and delete the LL value to see how the geocoding for missing values works. Delete the LL and mess up the address to see what happens with a bad address. (Naturally, for your real pages you'd use [ showif ] to display the editing link only to the administrator. And you will protect this page as well.)
  • If you cannot get an address to geocode, find your location on a Google map, and double click exactly on the location you want so the map zooms and centers. Now click the "link" link. Copy the linkcode and paste it into a text editor. Find the variable "ll" and copy those coordinates to the LL field in your database just as they are in the link code: separated with a comma, no spaces. Be careful NOT to use the "sll" variable. If you don't find the "ll" variable, make sure the map centered after you double-clicked it. Also use this technique to determine the centerpoint of your default map.
  • Notice that you can tweak the coordinates to move the pinpoint around if Google maps your address not exactly where the building really is. Play around with it to see how you can move the pin.
  • You may create new records using the link below.
  • A closedatabase tag is at the top of the page in case you'd like to edit the addresses.db file directly.

[submit] RECORD [id] SUCCESSFUL
Name
Facility
Address
Zip
Name
Facility
Address
Check map based on address
Zip
Long, Lat [hideif [ll]=]
Check map based on Long, Lat [/hideif][showif [ll]=]geocode address [/showif]
Address (street + zip): [thisaddress]
ID: [ID]

[text]ll=[middle startafter=ll=&endbefore=",deleted][response][/middle][/text] [hideif [ll]^HTTP/1.0] [!] **** Is good: but hides replace code when long/lat not determined due to flakey address ****[/!] [replace db=[db]&eqIDdatarq=[id]]ll=[ll][/replace] SUCCESSFULLY Geocoded
Long, Lat: [ll]

[/hideif] [showif [ll]^HTTP/1.0] [!] **** flakey address - returns error page instead of the clean variable, hence the HTTP/1.0 ****[/!] Oops! Google couldn't figure out the address. Please FIX ADDRESS and try again.
Map the address

Modify the existing address or intersection to work (use the Check Map link to check). If still no good, try a search on the location name (if a named location, like a business or church) + zip code in the google map search box. Often this brings up a better address. Check it with the satellite view to make sure it's where it should be.

All else fails, crawl around on the map until you find your location, then double-click to center the map. Fetch the LL coordinates (see above) and add them to the LL field.

If the street is mispelled, zip code wrong, or "st" "ave" "blvd" "rd" etc. not correct, these will all cause a failure. Route numbers can be tricky too.

[/showif]

[showif [found]=0] Good news: no records are missing the Long/Lat data.

[/showif]
[hideif [id]=[raw][id][/raw]] Edit Record [id] |[/hideif] New Record | View Map | Check for missing geocodes


This WebDNA module is copyright 2010 by Terry Wilson. Permission granted to WebDNA Software Corp. for distibution to users. [!] [formvariables][name]=[value]
[/formvariables]

[listvariables][hideif [name]=response][hideif [name]=ll][/hideif][/hideif][name]=[value]
[/listvariables] [/!]