Я делаю карту с Google Maps, но у меня есть эта ошибка
markerclusterer.ts:818 Uncaught (in promise) TypeError: e.getDraggable is not a function
at r.value (markerclusterer.ts:818)
at r.value (markerclusterer.ts:801)
at new r (markerclusterer.ts:345)
at initMap (VM2170 map:82)
at js?key=&callback=initMap:142
at js?key=&callback=initMap:142
Я получаю города из своей базы данных и использую api google geocoder.geodecode для получения координат из городов. После того, как я использую markercluster для создания кластеров, но это не работает. Я думаю, это потому, что он ожидает другой формат, чем тот, который указан в geodecode.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 5,
center: {lat: 48.856614, lng: 2.3522219}
});
map.setOptions({draggable: true});
// Create an array of alphabetical characters used to label the markers.
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
//var markers = locations.map(function(location) {
// return new google.maps.Marker({
// position: location,
// });
//});
//console.log(markers);
var geocoder = new google.maps.Geocoder();
var list = cityslist.map(function(city, i){
return new geocoder.geocode({'address': city}, function(results, status) {
if (status === 'OK') {
console.log(results);
console.log(results[0].geometry.bounds['Ya']['i']);
console.log(results[0].geometry.location.lat);
var abc = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
});
return abc;
};
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, list,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder, map);
});
}