[英]Uncaught TypeError: Object[object Object] has no method 'x' at file y Error
I'm using LeafLet in Android and I'm trying to show edited coordinates in alert. 我在Android中使用LeafLet,并尝试在警报中显示已编辑的坐标。
HEAD 头
<head>
<link rel="stylesheet" href="leaflet.css" />
<link rel="stylesheet" href="leaflet.draw.css" />
<script src="leaflet.js" type="text/javascript"></script>
<script src="leaflet.draw.js" type="text/javascript"></script>
<script src="tmp.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
<script src="webintent.js" type="text/javascript"></script>
<script src="json2.js" type="text/javascript"></script>
<style type="text/css">
#map { height: 100%;
width: 100%; }
</style>
</head>
Here is my function 这是我的功能
map.on('draw:edited', function (e) {
// Update db to save latest changes.
var layers = e.layers;
layers.eachLayer(function(layer) {
alert(layer.getLatLngs().toString()); //this is 114. command line
});
});
When i try this on web browser, it is working good.. But when I try this in Android, I'm getting this error. 当我在网络浏览器上尝试此程序时,它工作正常。.但是,当我在Android中尝试此程序时,出现此错误。
Any suggestion ? 有什么建议吗?
10-18 16:22:05.240: E/Web Console(4459): Uncaught TypeError: Object [object Object] has no method 'getLatLngs' at file:///android_asset/www/main.html:114 10-18 16:22:05.240:E / Web控制台(4459): 未捕获的TypeError:对象[object Object]在file:///android_asset/www/main.html:114上没有方法“ getLatLngs”
It's a typo. 这是一个错字。 It should be
alert(layer.getLatLng().toString());
应该是
alert(layer.getLatLng().toString());
. 。
Andy thanks for solution but it is not typo. 安迪感谢您的解决方案,但这不是错字。
If you are working with Markers , you have to use getLatLng() function because Marker has only one LatLng. 如果您正在使用Markers ,则必须使用getLatLng()函数,因为Marker只有一个LatLng。
If you are working with more than 1 point like polygon, polyline, you have to use getLatLngs() function. 如果使用的是1点多像多边形,折线工作,你必须使用getLatLngs()函数。 I was working with Marker and i was trying to use getLatLngs() with Marker.
我正在与Marker合作,并且试图与Marker一起使用getLatLngs()。 That was the problem
那是问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.