0

I want to use the textSearch method from google place library api without the maps.I have the longitude,latitude,place's name which I want to search.Now I just want to send the request to google and use the results.I have included the script

<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?&libraries=places"></script>

But I now have to use the PlaceService and for that I think I need to include maps in my app which I don't want.

var service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);

I just need to search the place with longitude,latitude and radius.I have try making the request directly by generating the url and sending the ajax request.But it return

No 'Access-Control-Allow-Origin' header is present on the requested resource

How do I search the text in my ember app ?

nandanself
  • 835
  • 8
  • 21
  • related question: [PlacesService and the need of html node](http://stackoverflow.com/questions/27990005/placesservice-and-the-need-of-html-node) – geocodezip Feb 01 '16 at 14:28

2 Answers2

0

The PlaceService constuctor takes either a google.Maps.Map object or a HTML div (it doesn't_have_ to be a map, but there has to be a place for it to display warnings, etc.)

PlacesService(attrContainer:HTMLDivElement|Map) Creates a new instance of the PlacesService that renders attributions in the specified container.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
0

Using the Places-Library does not require a map.

When you print results(without a map) you must:

  1. display the google-logo: https://developers.google.com/maps/documentation/javascript/places#LogoRequirements
  2. Print the attributions(if there are any) . Therefore you must supply a Node as argument for PlacesService

service = new google.maps.places.PlacesService(
  document.getElementById('attributions')//attributions-container
);

//send a query
service.textSearch({query:'Stackoverflow'}, function(results, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    for (var i = 0; i < results.length; i++) {
      var item=document.createElement('li');
      item.appendChild(document.createTextNode(results[i].name));
      document.getElementById('results').appendChild(item);
    }
  }
});
<script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=places"></script>
<strong>Search for &quot;Stackoverflow&quot; </strong><br/>

<!-- google-logo -->
<img src="http://developers.google.com/places/documentation/images/powered-by-google-on-white.png"/>

<ul id="results"></ul>

<!-- attributions-container -->
<div id="attributions" style="background:#f1f1f1">
  You'll see here the attributions when there are any
</div>
Dr.Molle
  • 116,463
  • 16
  • 195
  • 201