9

I am building an android application which would store latitude and longitude information from google maps. The application receives the Send/Share intent from Google maps when user chooses location from map and extracts co-ordinates by un-shortening the goo.gl map link (e.g. http://goo.gl/maps/FcglP) embedded in intent. This task is easy if the location being shared from google maps is unknown or named "dropped pin". In that case the un-shortened URL looks like

http://maps.google.com/?q=17.50122123,74.12351323&.....

If the location is well known (http://goo.gl/maps/FcglP), e.g. some road, un-shortened URL looks like

http://maps.google.com/?q=Sutarwadi+Baner+Gaon+Rd%2C+Baner&ftid=0x3bc2becfa70b8b3f:0xd210c15f634bcec3&hl=en&gl=us

I have been searching for last three hours about how to extract the co-ordinates from this kind of URL but couldn't find any information. Is there any other method to extract co-ordinates from a given goo.gl map URL? Some already developed library or google API?

enli
  • 109
  • 1
  • 1
  • 5

2 Answers2

4

2 steps:

Pavel Bucek
  • 5,304
  • 27
  • 44
davelerat
  • 49
  • 1
  • 2
  • 2
    this works, but it means downloading 10k of data. Anyone know a way to parse the `ftid=` part for the lat/long? It looks like it could be a lat/long. – Hans-Christoph Steiner Jan 09 '15 at 14:51
  • https://stackoverflow.com/questions/51907305/get-latitude-longitude-from-url-google-maps/63842716#63842716 check this answer – AmmAr Yasser Sep 11 '20 at 08:30
0

function myMap() {

var mapUrl = $('.map').html();
var url = mapUrl.split('@');
var at = url[1].split('z');
var zero = at[0].split(',');
var lat = zero[0];
var lon = zero[1];

var mapProp= {
        center:new google.maps.LatLng(lat,lon),
        zoom:5,
};
var map = new google.maps.Map(document.getElementById("mapL"),mapProp);

}