- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试将我的 googlemaps v2 功能移植到 v3。
但不知何故我陷入了一个奇怪的错误,我找不到我做错了什么。
Error : Uncaught InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lat: not a number %7Bmain,adsense,geometry,zombie%7D.js:25
这里是我的 map 初始化:
var map = new google.maps.Map(document.getElementById("map"),{
zoom:4
size:new google.maps.Size(580,440),
mapTypeControl: true,
mapTypeControlOptions: {
style:google.maps.MapTypeControlStyle.VERTICAL_BAR,
position: google.maps.ControlPosition.BOTTOM_CENTER,
},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.TOP_LEFT,
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.LEFT_CENTER,
},
scaleConrol: true,
scaleControlOptions:{
position: google.maps.ControlPosition.TOP_LEFT ,
},
});
map.setCenter(new google.maps.LatLng(49.477643, 9.316406));
这里是我出错的部分:
function drawTraders(map, options) {
var traders_uri = options.traders_uri || '';
if ('' == traders_uri) {
return false;
}
// get the informations
$.getJSON(traders_uri, function(data) {
// look through the information
$.each(data.traders, function(i, trader) {
var icon = options.icon_image_uri;
var markerIcon = new google.maps.MarkerImage(icon,
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(25, 25),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(0, 32)
);
var html = 'test';
/*Information from chromium debugger
trader: Object
geo: Object
lat: "49.014821"
lon: "10.985072"
*/
var myLatlng = new google.maps.LatLng(trader.geo.lat,trader.geo.lon);
/*here is the error in new google.maps.Marker()*/
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon : markerIcon,
});
var infowindow = new google.maps.InfoWindow({
content: html
});
}
编辑:drawTraders 的调用
drawTraders(map, {
traders_uri: "getTraders.php",
icon_image_uri: "icon-cms.gif",
});
我正在使用这个例子 Info Window
编辑:
最佳答案
Uncaught InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lat: not a number
意味着您没有将数字 传递给 google.maps.LatLng 构造函数。根据您的评论:
/*Information from chromium debugger
trader: Object
geo: Object
lat: "49.014821"
lon: "10.985072"
*/
trader.geo.lat 和 trader.geo.lon 是字符串,不是数字。使用 parseFloat 将它们转换为数字:
var myLatlng = new google.maps.LatLng(parseFloat(trader.geo.lat),parseFloat(trader.geo.lon));
关于javascript - 如何修复未捕获的 InvalidValueError : setPosition: not a LatLng or LatLngLiteral: in property lat: not a number?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20585055/
我正在使用 MySQL 5.5.52。缩写:Lat = 纬度,Long = 经度,NE = 东北,SW = 西南。 我有两个 SQL 表: 第一个表包含“区域”。每个区域由 ID、NE Lat、NE
这个问题在这里已经有了答案: Measuring the distance between two coordinates in PHP (13 个答案) 关闭 9 年前。 我在数据库中存储了 fi
我试过以下方法,输入:纬度/经度数据然后我会计算它周围的一个方框,比方说 50 米,所以东距/北距值 +/- 50 米。 现在我将它重新转换为纬度/经度并使用脚本: http://robotics.a
我想在 Google map 标记完成拖动时检索正确的 lat/lng。 但是对于同一个精确点,它给出了两个不同的(非常近似)坐标。 同一掉落的示例结果: evt.latLng:39.82213542
我正在使用 proj4 将纬度/对数坐标投影到 UTM。但我无法从 UTM 投影回 lat/log。对于以下示例,我希望代码返回给定的经纬度/对数 [48.37966, 2.504635]。相反,它返
我有一个 mysql 插入语句,当系统无法获取用户的纬度/经度时,该语句会中断。sql 是这样的: INSERT INTO users(user_email, first_name , last_na
我有一个页面,用户可以在“邮政编码”字段中输入他们的地址。我还有一个“检测位置”按钮,可以对用户地址进行地理定位。当他们单击此按钮时,他们的城市名称和邮政编码将回显到“邮政编码”字段中,并且纬度和经度
添加位置并按回车键时出现错误 var lat = data.results[0].geometry.location.lat; 类型错误:无法读取未定义的属性“结果” 有时它会给出 cannot re
我有两个表:一个 map 表,其中包含大约 3,000 个纬度/经度对,代表现实世界的“标记”位置;还有一个建筑物表,其中有数百个纬度/经度对,也代表真实世界的建筑物位置。我想做的是获取所有建筑物可见
我正在尝试找到解决以下问题的最佳方法: 问题 我在集合 A 中有(最多)100,000 个纬度/经度点我在 B 组中有(最多)2000 个纬度/经度点 我需要找到集合 B 中的点与集合 A 中的点最近
我有一个圆圈,它实际上是一个以米为单位的半径的 latlon 位置。我还有一条道路 A-B 定义为两个经纬度位置。我如何找到那条路是否在圆圈内交叉。如果没有将 latlon 位置投影到 xy 位置是否
假设我有一个 lat lng 坐标,我想把它放在一个 10 公里宽的正方形的中心,然后得到最小的 lat/lng 和最大的 lat/lng。 有没有一种简单的方法可以做到这一点已经存在? 最佳答案 如
我有一个类型为 (com.vividsolutions.jts.geom.Geometry) 的几何对象。它目前处于纬度、经度形式,我想翻转坐标,以便它的经度纬度,以便我可以将它以 GeoJSON 格
我想在android中制作一个应用程序。在此应用程序中,用户必须在此应用程序中注册。注册后,GPS 位置(纬度和经度)将与用户信息一起存储在数据库表中。在这个应用程序中,我想添加一个功能,即“搜索根目
在过去的几天里,我一直在努力寻找这个问题的答案。我有一个 GPS 数据路线表。和一张积分表。我需要的是一个 MySql 语句,对于给定的路线,将告诉我两个端点的 Point.Name。我可以写 4 个
我正在尝试从我的解析后端查询一组坐标(纬度和经度)。然后将它们用作 map 上的注释。虽然一旦我从解析中查询后,我不确定如何将坐标转换为 CLLocation。 查询使用的代码: var usersL
我见过这个问题的许多变体,但我无法将他们的答案与我的具体需求联系起来。 我有几组 3 纬度/经度坐标对。任何集合中的坐标彼此之间都在几公里之内。 对于每个集合,我想将坐标转换为 x/y 值,以便我可以
我希望能够找到离经度/纬度元组最近的位置的经度/纬度坐标索引。这已经在 Java API 中作为 GridCoordSystem.findXYindexFromLatLon() 提供,但我还没有在
我对这些字段的数据类型感到困惑。我想获取存储在手机上的图像的经度和纬度,并将其表示为地理点。我的代码是: double long_ = imageCursor.getDouble(imageCurso
我有以下交通表,其中包含数千条火车、巴士站和机场的记录。 ID Lon Lat Name 1 0.375
我是一名优秀的程序员,十分优秀!