gpt4 book ai didi

api - "marker.getPosition is not a function"而 markerclustering

转载 作者:行者123 更新时间:2023-12-05 06:36:56 32 4
gpt4 key购买 nike

<分区>

结果给我这个错误:“TypeError: marker.getPosition is not a function”。

我对 markerClustering 进行了多次搜索,但找不到任何错误解释!

我的变量 myMarkers 是 MarkerClusterer 文档中要求的数组。

如果有人能帮助我,我将不胜感激:)

function initMap(){

var maDataBase = [];
var myMarkers = [];

$.getJSON( "https://api.jcdecaux.com/vls/v1/stations?contract=MY-CONTRACT&apiKey=MY-API-KEY", function( data ) {
$.each( data, function( key, val ) {
maDataBase.push(val);
});
}).done(function(){

var bounds = new google.maps.LatLngBounds();
var myMap = $('.main')[0];
var mapOptions = {
mapTypeId : google.maps.MapTypeId.ROADMAP
};

var googleMap = new google.maps.Map(myMap, mapOptions);

for (var i = 0; i < 50; i++){

myMarkers.push(new google.maps.LatLng(maDataBase[i].position.lat, maDataBase[i].position.lng));

for (var x = 0, marker; x < myMarkers.length;x++){

bounds.extend(myMarkers[i]);

marker = new google.maps.Marker({
map : googleMap,
position: myMarkers[i],
});
}

};

googleMap.fitBounds(bounds);
var markerCluster = new MarkerClusterer(googleMap, myMarkers,{imagePath: '../img/m'});

});

};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JCDecaux</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
</head>
<body>
<div class="main" id="main">

</div>




<script async defer src="https://maps.googleapis.com/maps/api/js?key=MY-API-KEY&callback=initMap"></script>
<script src="js/markerclusterer.js"></script>

<script src="js/jquery.min.js"></script>

<script src="js/main.js"></script>
</body>
</html>

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com