I am developing an app in which I need to do check-ins at various places provided by Google API. the problem is that the API does not provide all the registered places. I have added all the place types in the nearby search parameters but still no markers coming on those places. If anybody knows please help. following is code for nearby search. I have added a lot of places but still not get markers
function loadNearByPlaces(latLng) {
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
location: latLng,
radius: 5000,
// type: ['any']
types: ['airport', 'amusement_park', 'aquarium', 'art_gallery', 'bar', 'book_store', 'bowling_alley', 'cafe', 'casino', 'church',
'clothing_store', 'department_store', 'gym', 'hospital', 'library', 'lodging', 'museum', 'night_club', 'park', 'restaurant', 'rv_park',
'school', 'shopping_mall', 'stadium', 'university', 'zoo', //my own types,
'bank', 'bakery', 'bus_station', 'car_wash', 'city_hall', 'post_office', 'shopping_mall', 'subway_station', 'university',
'furniture_store', 'fire_station', 'embassy', 'pharmacy', 'convenience_store', 'shoe_store', 'spa', 'train_station', 'transit_station',
'police', 'doctor', 'courthouse', 'roofing_contractor', 'hair_care', 'local_government_office', 'jewelry_store', 'lawyer', 'locksmith',
'accounting', 'cemetery', 'car_dealer', 'florist', 'home_goods_store', 'store', 'synagogue', 'laundry', 'insurance_agency', 'point_of_interest',
'post_box', 'colloquial_area', 'food', 'general_contractor', 'intersection', 'locality', 'neighborhood', 'subpremise', 'place_of_worship',
'political', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'administrative_area_level_4',
'administrative_area_level_5', 'colloquial_area', 'country', 'establishment', 'finance', 'floor', 'food', 'geocode', 'health', 'intersection', 'locality', 'natural_feature',
'neighborhood', 'place_of_worship', 'political', 'point_of_interest', 'post_box', 'postal_code', 'postal_code_prefix', 'postal_code_suffix', 'postal_town',
'premise', 'room', 'route', 'street_address', 'street_number', 'sublocality', 'sublocality_level_4', 'sublocality_level_5', 'sublocality_level_3',
'sublocality_level_2', 'sublocality_level_1', 'subpremise', 'Indiana Convention Center'
]
}, callback);
Actually i got the solution after some research. Google maps api provides 20 locations per call and can return upto 60 locations. we don't need to specify types in params rather we have to call pagination again and again (it will be called 3 times) Each call will result in an addition of 20 markers. I modified the code as
function loadNearByPlaces(latLng) {
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
location: latLng,
radius: 100
}, callback);
}
function callback(results, status, pagination) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
// places.push(results[i])
}
if (pagination.hasNextPage) {
pagination.nextPage();
}
}
}