JFKay
JFKay

Reputation: 39

Google map geocode places

So I am working with google maps on a project I need to get lat&lng from a place name (not city but a, lets say, caffee in a city, or a mall in a city). So I went with this code

var geocoder =  new google.maps.Geocoder();
        geocoder.geocode( { 'address': 'SCC, Sarajevo'}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
            $("#pretragaBarInput").val("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng());
          } else {
            alert("Something got wrong " + status);
          }
        });

(SCC is a mall in Sarajevo) But I dont get the exact lat&lng from the place but rather lat&lng from the city center. I've tried with other places but got the exact same coords that point to the city center

P.s. This is just a debug script to see if its working...

Upvotes: 0

Views: 59

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117354

Geocoding is for addresses(although it also may return the desired result for prominent places).

When you are searching for places uses the places-library, e.g. a PlacesService.textSearch

(returns: Sarajevo City Center, Vrbanja 1, Sarajevo 71000)

Upvotes: 1

Related Questions