Google maps api can't read placesservice

I have a problem with the Google Maps API and its PlacesService. Despite the fact that I loaded the place library correctly, it says: "It is not possible to read the" PlacesService "property from undefined." The card itself works and loads. Any ideas? Here is the code:

<div id="map-canvas"></div> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&libraries=placeβ€Œs"></script> <script type="text/javascript"> var myLatlng; var map; var marker; function initialize() { myLatlng = new google.maps.LatLng(fooLat, fooLng); var mapOptions = { zoom: 17, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false, draggable: true }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var service = new google.maps.places.PlacesService(map); var request = { placeId: 'fooPlaceId'}; service.getDetails(request, callback); function callback (place, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { marker = new google.maps.Marker({ position: place.position, map: map, title: place.name }); } }; } google.maps.event.addDomListener(window, 'load', initialize); </script> 

Update: I literally just tried a piece of code from Google itself , and it gave me the same error.

+7
javascript google-maps google-maps-api-3 google-places-api
source share
2 answers

Here's the answer: I copied the include line directly from some page (or here, stackoverflow or one of the Google API example pages. The problem is that for some reason it had an invisible character in the name of the library that my CMS editor did not type Therefore, be careful when copying!

-2
source share

This example requires the Places library. Turn on the libraries=places parameter when you first load the API using the API key.

For example:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">

+18
source share

All Articles