Monday, January 24, 2011

Quick Groovy Script! Google Geocoding!

Nice little script for parsing the Google Ceocoding Web Service. (Groovy 1.7.5)


/**
Simple Script to parse the google geocode web service
http://code.google.com/apis/maps/documentation/geocoding/
*/
def url = new URL('http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true')
def geoCodeResult = new XmlParser().parseText(url.getText())
def lat = geoCodeResult.result.geometry.location.lat.text()
def lng = geoCodeResult.result.geometry.location.lng.text()
println lat
println lng


Outputs :
37.4216227
-122.0840263

3 comments:

  1. I used this geocoding in one of my personal projects

    ReplyDelete
  2. Hey, thanks for this post! Just a question, does this pose any issues regarding the synchronous/asynchronous issue like javascript does?

    ReplyDelete
  3. Hello, i am from USA, I want to share this great testimony about how Dr.Agbazara helped me bring back my ex lover, During my search for solution i came in contact with Dr.Agbazara details and through his help my lover came back to me within 48 hours. So with these i am so bold to advise anyone seeking for a way to get there lover back to contact Dr.Agbazara on WhatsApp: { +234 810 410 2662 } or via email at: { agbazara@gmail. com } I am so happy at least myself and my lover are back to each other again and going to spend the New Year celebration together Thank to Dr.Agbazara once again....

    ReplyDelete