Finded the solution.
I need to convert my map into a google map adding this line before the call to placeRequest
var map = new google.maps.Map(document.getElementById(map),mapOptions);
Question
Good morning,
I have a site where I would like to populate a select passing latitude and longitude of a place.
I have create many function in javascript to call google api place search to retrieve places.
The problem is that I retrieve an error out of range
.
This is my code:
$(document).ready(function(){
function change_interest_point(city_id, map, lat, lng){
var myLatlng = new google.maps.LatLng(lat, lng);
$('.icon-place').each(function(index){
val = $(this).attr('id');
icon = $(this).data('icon');
up206b.placesRequest('',myLatlng,'5000',[val],icon,map, 'interest-point');
});
}
});
var up206b = {};
up206b.placesRequest = function(title,latlng,radius,types,icon,map, select)
{
//Parameters for our places request
var request = {
location: latlng,
radius: radius,
types: types
};
var callPlaces = new google.maps.places.PlacesService(map);
callPlaces.search(request, function(results,status){
$.each(results, function(i,place){
var placeLoc = place.geometry.location;
$('#myselect').append('<option value="' + placeLoc.lat() + ', ' + placeLoc.lng() + '">' + place.name + '</option>');
})
});
}
html:
<div id="airport" class="icon-place" data-icon="icon.png">
<div id="aquarium" class="icon-place" data-icon="icon.png">
<div id="bus_station" class="icon-place" data-icon="icon.png">
<div id="car_rental" class="icon-place" data-icon="icon.png">
<div id="casino" class="icon-place" data-icon="icon.png">
<div id="church" class="icon-place" data-icon="icon.png">
<div id="museum" class="icon-place" data-icon="icon.png">
<div id="night_club" class="icon-place" data-icon="icon.png">
<div id="park" class="icon-place" data-icon="icon.png">
<div id="restaurant" class="icon-place" data-icon="icon.png">
<div id="subway_station" class="icon-place" data-icon="icon.png">
<div id="train_station" class="icon-place" data-icon="icon.png">
And this is the error:
TypeError: this.b[Nb] is not a function
(269 out of range 57)
Logically if I remove the call of search places this error there isn't.
Solution
Finded the solution.
I need to convert my map into a google map adding this line before the call to placeRequest
var map = new google.maps.Map(document.getElementById(map),mapOptions);