Javascript 谷歌地图错误:不是LatLng或LatLngLiteral:不是对象-似乎与“边界”相关
我从谷歌电子表格中导入地址,并将它们放在谷歌地图上。位置纬度和经度存储在变量中。我循环遍历所有条目并创建标记。 谷歌电子表格和网站之间的连接正常,但它只显示了第一个条目。所以这似乎是一个循环的问题 首先,我认为_location.latitude//u location.longitude中的值有问题,我尝试在那里设置.value,但这不是问题所在 循环位于_setLocations函数中,从我的搜索结果来看,var _bounds或_bounds.extend似乎存在一些问题Javascript 谷歌地图错误:不是LatLng或LatLngLiteral:不是对象-似乎与“边界”相关,javascript,json,google-maps,google-maps-api-3,Javascript,Json,Google Maps,Google Maps Api 3,我从谷歌电子表格中导入地址,并将它们放在谷歌地图上。位置纬度和经度存储在变量中。我循环遍历所有条目并创建标记。 谷歌电子表格和网站之间的连接正常,但它只显示了第一个条目。所以这似乎是一个循环的问题 首先,我认为_location.latitude//u location.longitude中的值有问题,我尝试在那里设置.value,但这不是问题所在 循环位于_setLocations函数中,从我的搜索结果来看,var _bounds或_bounds.extend似乎存在一些问题 _createG
_createGoogleMap: function(_mapID){
var _this = this;
var _locations = [];
var _sheetUrl = 'https://sheets.googleapis.com/v4/spreadsheets/xxxxxxxxxxxxxxxxxxx/values/Sheet1!A2:U?key=xxxxxxxxxxxxxxxxxxxxxx';
var _map = new google.maps.Map(document.getElementById(_mapID), this._mapProp);
$.getJSON(_sheetUrl, function(data) {
$(data.values).each(function() {
var _location = {};
_location.latitude = parseFloat(this[8]);
_location.longitude = parseFloat(this[9]);
_locations.push(_location);
});
_this._setLocations(_map, _locations);
});
},
当我“console.log_locations;”在循环之前,
我得到了所有的地址,但是循环之后我什么也没有得到
再也没有了
非常感谢您的帮助。尝试使用合适的LatLng对象
my_location = new google.maps.LatLng(_locations[i].latitude, _locations[i].longitude) ;
var _new_marker = _this._createMarker(_map, _my_location, _infowindow);
GoogleMapsLatlInteral具有.lat和.lng属性,而不是.latitude和.longitude属性。
my_location = new google.maps.LatLng(_locations[i].latitude, _locations[i].longitude) ;
var _new_marker = _this._createMarker(_map, _my_location, _infowindow);