【发布时间】:2019-06-18 11:21:04
【问题描述】:
此功能的想法是,当用户输入一个位置时,我们会在该位置添加一个标记,然后平移所述标记并放大该标记的位置。然而,所有这些都工作得很好。它给了我这个错误“ Uncaught Kc {message:”not a LatLng or LatLngLiteral: not an Object”, name: “InvalidValueError”。”
if(map.getZoom() == 2) {
map.setCenter({lat:data.address_lat2, lng:data.address_lng2});
map.panTo(marker.position);
smoothZoom(map, 11, map.getZoom());
var location = new google.maps.LatLng({lat:data.address_lat2, lng:data.address_lng2});
var bounds = new google.maps.LatLngBounds();
bounds.extend(location.position);
map.fitBounds(bounds);
}
这是我的平滑缩放功能
function smoothZoom (map, max, cnt) {
if (cnt >= max) {
return;
} else {
z = google.maps.event.addListener(map, 'zoom_changed', function(event){
google.maps.event.removeListener(z);
smoothZoom(map, max, cnt + 1);
});
setTimeout(function(){map.setZoom(cnt)}, 150);
}
}
【问题讨论】:
-
请提供minimal reproducible example来证明您的问题。
-
这是一个相当大的代码库,有些方面依赖于其他方面。尤其是输入邮政编码或位置,因此提供一个最小的示例将需要相当长的时间。当我继续我一天的工作时间时,我会继续这样做。
标签: javascript google-maps google-maps-api-3 maps