2

I have this link:

http://www.google.com/maps?cid=0,0,612446611849848549&f=q&source=embed&hl=en&geocode=&q=Универзална+Сала+&sll=,&&ie=UTF8&hq=&hnear=Универзална+Сала+&ll=,&z=15&iwloc=near

What I want is to retrieve the Lat Lng of the pinpointed place. I have already tried to use the geocoding API:

http://maps.googleapis.com/maps/api/geocode/xml?q=Универзална+Сала+&sensor=false

but I am getting no results because the pinpoint refers to a place and not an address.

How do I obtain the Lat Lng of the pinpoint based on the link? (I need this through code, since I am scraping a site)

Community
  • 1
  • 1
Glad To Help
  • 5,299
  • 4
  • 38
  • 56
  • which google api version you used v2/v3? do you need in javascript or in another language – Pratik Aug 04 '11 at 11:04
  • Shameless self promotion, but it might be worth taking a look at my project that seems to do just this: http://davgothic.com/geocoder. You can find the source code on [github](https://github.com/davgothic/Geocoder). – David Hancock Aug 04 '11 at 11:10
  • V3, and I need it in PHP – Glad To Help Aug 04 '11 at 11:51

1 Answers1

0

You can get Lat Lng information from the response for this link. The response of this link would be an html file of google map. The position information is written somewhere in the javascript code inside the html. You can find the pattern "viewport:{center:{lat:xxx,lng:xxx}}" in the javascript code. For instance I found the lat and lng of your link is 41.999227 and 21.416496, which is the center of the map as well as the pinpointed place. Or you can find the markers position if you have more than one result:

codes for map center information:

viewport: {
    center: {
       lat: 41.999227,
       lng: 21.416496
    },
    span: {
        lat: 0.006295,
        lng: 0.006295
    },
    zoom: 15,
    mapType: 'm',
    source: 0
},
...

codes for the markers:

markers: [{
    id: 'A',
    cid: '612446611849848549',
    latlng: {
        lat: 41.999227,
        lng: 21.416496
    },
    ... 

In this case, the center of map and the marker has the same latlng information.

jz1108
  • 1,300
  • 1
  • 11
  • 14