google maps api不会渲染地图,因为它说我在经纬度部分给出的坐标不是数字。返回此控制台错误
InvalidValueError:setCenter:不是LatLng或LatLngLiteral:在属性lng中:不是数字
function initMap(){
const mapHere = document.getElementById("map");
const marker0 = {
lat: -38.414506,
long: 144.851985
};
const marker1 = {
lat: -38.404351,
long: 144.841955
};
const line = [marker0, marker1];
if (mapHere) {
const map = new google.maps.Map(mapHere, {
zoom: 8,
mapTypeId: google.maps.MapTypeId.HYBRID,
center: marker0
});
const marker_0 = new google.maps.Marker({
position: marker0,
map: map,
title: "marker 0"
});
const marker_1 = new google.maps.Marker({
position: marker1,
map: map,
title: "marker 1"
});
const lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4
};
var flightPath = new google.maps.Polyline({
path: line,
geodesic: true,
strokeColor: '#f8fc09',
strokeOpacity: 0,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '20px'
}],
strokeWeight: 2
});
flightPath.setMap(map);
}
}
这是我用来渲染地图的代码,它是针对每个循环在php中生成的一部分。
有什么想法吗?
答案 0 :(得分:2)
它应该是'lng'而不是'long'。