-1

Ich entwickle eine App, in der ich Check-Ins an verschiedenen Stellen durchführen muss, die von Google API bereitgestellt werden. Das Problem ist, dass die API nicht alle registrierten Orte bereitstellt. Ich habe alle Ortstypen in den Suchparametern in der Nähe hinzugefügt, aber immer noch keine Markierungen an diesen Orten. Wenn jemand weiß, bitte helfen Sie. Folgendes ist Code für die Suche in der Nähe. Ich habe viele Orte hinzugefügt aber immer noch keine MarkierungenGoogle API zeigt keine Markierung an allen registrierten Orten an

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); 
+3

Bitte schreiben Sie relevanten Code und Fehler. – Spechal

+0

Ich habe Code @Spechal hinzugefügt. Sorry, ich konnte es gestern nicht hochladen –

Antwort

0

Eigentlich habe ich die Lösung nach einigem Nachforschungen. Google Maps API bietet 20 Standorte pro Anruf und kann bis zu 60 Standorte zurückgeben. Wir müssen keine Typen in Params angeben, sondern müssen die Seitennummerierung immer wieder aufrufen (sie wird 3 Mal aufgerufen). Jeder Aufruf führt zu einer Addition von 20 Markern. Ich änderte den Code als

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(); 
     } 
    } 
} 
Verwandte Themen