I have this string of code from one of their examples that I'm trying to reverse engineer.

<script type="text/javascript">
  function initialize() {
    var map = new google.maps.Map(document.getElementById('map_canvas'), {
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: new google.maps.LatLng(36.018486,-86.787607),
      zoom: 15
    });
    var frontline = new google.maps.LatLng(36.018486,-86.787607);

    var request = {
      reference: 'CnRkAAAAGnBVNFDeQoOQHzgdOpOqJNV7K9-c5IQrWFUYD9TNhUmz5-aHhfqyKH0zmAcUlkqVCrpaKcV8ZjGQKzB6GXxtzUYcP-muHafGsmW-1CwjTPBCmK43AZpAwW0FRtQDQADj3H2bzwwHVIXlQAiccm7r4xIQmjt_Oqm2FejWpBxLWs3L_RoUbharABi5FMnKnzmRL2TGju6UA4k'
    };

    var infowindow = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService(map);

    service.getDetails(request, function(place, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
        var marker = new google.maps.Marker({
          map: map,
          position: place.geometry.location
        });
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.setContent(place.name);
          infowindow.open(map, this);
        });
      }
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>

I can't figure out how to find the reference for my location.

Also, how would I get multiple values into

infowindow.setContent()
有帮助吗?

解决方案

I found that if you use the textSearch() method, that it provides the illusive reference string. I wrote a client side script that uses the textSearch() method to provide the reference string for the getDetails() method here.

其他提示

The long encrypted string is the Place reference, but it should only be used to go back and find the same place. Since it can change slightly it shouldn't be used to group ratings, check-ins, or other activity.

From the Places API documentation:

http://code.google.com/apis/maps/documentation/places/

"reference contains a unique token that you can use to retrieve additional information about this place in a Place Details request. You can store this token and use it at any time in future to refresh cached data about this Place, but the same token is not guaranteed to be returned for any given Place across different searches."

To add multiple values into the infowindow you just add what details you want show. Like this:

infowindow.setContent(place.name + address + rating);

var request Is where there are setting their data for the locations. Looks to be fairly encrypted.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top