Reputation: 143
I have only lon and lat. I need the address and phone no of the object at the given lon and lat. How would I do it using only JavaScript?
I additionally need to show a marker (infowindow.set(address and phone no)).
this is my code:
var marker = new google.maps.Marker({
position: new google.maps.LatLng(aCars[0],aCars[1]),
map: map,
title: 'My workplace',
clickable: false,
icon: 'images/images.png'
});
google.maps.event.addListener(marker,'mouseover',function() {
infowindow.setContent( );
infowindow.open(map, this);
});
Upvotes: 2
Views: 1860
Reputation: 11
You Can Use Geodatasource API to get a Place or area name! 500 req/month Free
fetch('https://api.geodatasource.com/city?
key=YOUR_KEY&&format=json&lat=22.3072&lng=73.1812')
.then((response) => response.json())
.then((responseJson) => {
Alert.alert(responseJson.city+","+responseJson.region)
console.log(responseJson.city);
})
.catch((error) => {
console.error(error);
});
Upvotes: 1
Reputation: 14447
Check out the reverse geocoding API by google, although i double you'll actually get a phone number, you'll have to talk to a phonebook api for that i'm afraid.
http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
Upvotes: 1