After some minor frustration today with CFMAP and the way it sends addresses to a geocoding service, I am now back on track. I just wanted to write a quick post for anyone else that may run into the same issue. CFMAP was leading me down the wrong path, telling me a bunch of addresses were invalid - "not found". When I directly used the geocoding functionality from Google to test the addresses i.e.
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
"http://maps.google.com/maps/geo?q=#address#&output=csv&sensor=false&ke y#yourgooglekey#
200,5,52.6006027,-1.1840779
1"http://maps.google.com/maps/geo?q=#address#&output=csv&sensor=false&ke y#yourgooglekey#
2200,5,52.6006027,-1.1840779
Google returned "ok" status code, including the longitude and latitude details I needed. The addresses was indeed valid as far as Google was concerned. So something else was afoot.
Next, I tried the longitude and latitude values in CFMAP and excluded address attribute. This time however all my 50 markers were loaded correctly with no errors.
I looked at the Google Maps API in more detail. I found they had implemented a geolocation service that takes the address you've supplied, and then converts it to longitude etc. As it turns out this geolocation service restricts the total number of requests, per second you can make. It seems CFMAP uses this same geolocation service when you don't have longitude or latitude in your map item tag.
Looking at my own source, ColdFusion makes all the requests to this service in just one call. After the confusing error message, I was beginning to think this was my issue and not that the addresses were invalid.
Anyhow, a quick Google, and Jedi Master to the rescue! Easy when you know what to search for, right?
Ray resolved this issue by calling a CFC to get the lat and lon points, then sleeping for 500ms before continuing in the loop, he saves the results into the application scope and then keep looping, checking if it exists until he has them all in this app scope.
I decided to use this solution, but in a different way. I did not want to use the application scope because my data changes to often.
So I change my approach. I created two new fields in my database for both longitude and latitude. When my users creates a new "address" via my backend, I create the Google Geocoder V3 CFC. And then save the results to a database. As my users add events one at a time, I would not run into the restriction here... Well, I could, but it's very unlikely, right?
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
// Geo Get Funtions
local.geo = createObject("component", "eventManagerApp.com.utility.googlegeocoder3");
local.geoResults = geo.googlegeocoder3(address="#rc.venueDetails.getvenueAddressLine1()# & #rc.venueDetails.getvenuePostCode()#");
// Save Geo Function
rc.venueDetails.setvenueLon(local.geoResults.longitude);
rc.venueDetails.setvenueLat(local.geoResults.latitude);
rc.venueDetails.setvenueAddressType(local.geoResults.result_type);
// Save
rc.venueDetails = geteventVenueService().save(entity=rc.venueDetails);
1// Geo Get Funtions
2local.geo = createObject("component", "eventManagerApp.com.utility.googlegeocoder3");
3local.geoResults = geo.googlegeocoder3(address="#rc.venueDetails.getvenueAddressLine1()# & #rc.venueDetails.getvenuePostCode()#");
4// Save Geo Function
5rc.venueDetails.setvenueLon(local.geoResults.longitude);
6rc.venueDetails.setvenueLat(local.geoResults.latitude);
7rc.venueDetails.setvenueAddressType(local.geoResults.result_type);
8// Save
9rc.venueDetails = geteventVenueService().save(entity=rc.venueDetails);
I could now use the raw longitude and latitude data without calling the geo service by using the address attribute and incurring the per second restrictions.
I loaded over 50 markers without any issues! Thank You... O, and what a run around!
Mura CMS - Shadowbox issues
Keith Ralston said: What are you using the shadow box to display? I have built a page for launching video in jw player w... [More]
Mura: New ORM Tag Attribute
cfJeff said: Thanks for sharing this little tidbit. I was just looking at integrating and external ORM applicat... [More]
API Authentication with Taffy
Glyn Jackson said: Thanks Spills. You are right if it’s not over HTTPS that it can be seen. You really don’t care who... [More]
API Authentication with Taffy
spills said: Thanks for a very detailed post with some awesome ideas. If this not being done over HTTPS your API ... [More]
Check file size before ColdFusion upload
Glyn Jackson said: Yes maybe I need to explain better. Normally you would have to FULLY upload the image. Of course, it... [More]