Quantum
Quantum

Reputation: 1476

Get Place details or building names using latitude and longitude in Google Maps(Places API ?)

Does anyone have any idea on how to get the place details under the Google Maps Places API using a latitude and longitude? I have tried Googling the solution, but can only find the reverse of it. So in short I need to get the place for a Latitude/Longitude.

Before someone says use geolocation, I'd say prove that one first as to me that would some like a shoot in the dark answer.

I have searched for hours on this and am unsure how to achieve this.

I have already read questions such as this that have gotten nowhere.

Just so it's clear, I have 46.73069,-117.16345999999999 which would be the place of "Bookie" at WSU with

"reference":"CmRUAAAAlgRCcYLe_HkYEFeUg9snExIKbgBTFVHTbyFkON1CTd58dH7iuJoyrPjXxWyEcoToa-Lrd7i__dpa83uGRBbrLeefEzz2hAL8pQPzx0YxHQPP4JNbrdKHW7LVUPJKwnHPEhA8PDSefSATZ6qWfT0eujRXGhRyBRL5P_vqpr7Tv7KigjgXmPJp6w"

Which if you look up the place via the reference you get the point but I need to pass the lat and long to find the places it matches.

Upvotes: 2

Views: 6217

Answers (3)

Quantum
Quantum

Reputation: 1476

Well I have moved forward, again to long for comments and not an additional infor type post so here is finds so far.

            var loca = new google.maps.LatLng(46.729757182529895,-117.1616792678833);
            var requested = {
              location: loca,
              radius:.1//,
              //keyword:"library"//,
              //types : ['establishment']

            };
            var service = new google.maps.places.PlacesService(map);
            service.search(requested, function(results, status){if (status == google.maps.places.PlacesServiceStatus.OK) {

        alert(JSON.stringify(results));

      for (var i = 0; i < 1; i++) {

        var request = {reference:results[i].reference};

        var service = new google.maps.places.PlacesService(map);
        //service.search(request, serach_callback);
        service.getDetails(request, function(place, status) {
          if (status == google.maps.places.PlacesServiceStatus.OK) {
              alert(JSON.stringify(place));
            var marker = markers[0];



            google.maps.event.addListener(marker, 'click', function() {
                ib.close();
              ib.setContent(setBoxHtml(JSON.stringify(place)));
              ib.open(map, this);
            });
          }
        });
        //createMarked(results[i]);
      }
    }});

does get me a place but it's the route and nothing more. I have to I guess give a key word or type to get anything else. lame for sure. the trouble is that it's not even correct with what the place is. If I use the type or keyword university under that same lat and long I'd think that I'd get the place that has those types of "university" which I can use http://www.google.com/mapmaker to prove that the place does in for sure have that set. And it does. But what I get as a result is the museum next door not the "CUE" which is what should have shown up.

There is some flaw here cause this is very unprdictable in not only how to get a place called up but on how to tell what places (with out types or keywords just all) are near your position. Even more is that the radius thou not in the doc does seem to have a min value of like 10 (I thnk) as 1 meter should only pick it's slef up yet it picks something at least 25 meters away.

Why can't i just call a place by ID and what can't I just get all the places for a radii of a lat and long? There has to be something simple cause I refuse to think that google's map api devs have missed the kiss of the whole thing.

Any ideas? Thanks -Jeremy

Upvotes: 0

Quantum
Quantum

Reputation: 1476

ok sorry i had more then a comments worth here..

So the deal is that you are just geting the address.. that is not a places entry. See here is an example of the issue. If you use local searches here http://gmaps-samples-v3.googlecode.com/svn/trunk/localsearch/places.html and now type in "pullman cue" you get the place, but if you use the new places http://code.google.com/apis/maps/documentation/javascript/examples/places-autocomplete.html you can't pull up the same place. Worse yet you can call the place you can call by reference which is weird to make it “Place, but the same token is not guaranteed to be returned for any given Place across different searches” and to be able to call by it but on the id which you can’t call by “It can be used to consolidate data about this Place, and to verify the identity of a Place across separate searches” as shown here http://code.google.com/apis/maps/documentation/javascript/examples/place-search.html .. so.. the deal is that i need the place "pullman cue" without using the depreciated api.

I just want to be able to get a place by something that is easy to do repeatedly.. idk

Upvotes: 1

duncan
duncan

Reputation: 31912

You want to do a reverse geocoding lookup: http://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding

This should 'prove' it to you: http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-reverse.html It doesn't display 'Bookie' in the infowindow, but I suspect if you used results[0] instead of results[1], that might have the business name. You're sort of vague on exactly what you're trying to do here; once you have the details what will you do with them? And which details do you require exactly?

Upvotes: 1

Related Questions