简体   繁体   English

未捕获的TypeError:对象[object Object]在文件y处没有方法'x'

[英]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.

相关问题 未捕获的TypeError:对象x没有方法&#39;css&#39; - Uncaught TypeError: Object x has no method 'css' JavaScript错误:未捕获的TypeError:对象[object Object]没有方法&#39;src&#39; - Javascript error: Uncaught TypeError: Object [object Object] has no method 'src' JQtouch错误:未捕获的TypeError:对象[object Object]没有方法&#39;live&#39; - JQtouch error : Uncaught TypeError: Object [object Object] has no method 'live' 未捕获的TypeError:对象# <error> 没有办法 - Uncaught TypeError: Object #<error> has no method 未捕获的TypeError:对象# <error> 没有方法“呼叫” - Uncaught TypeError: Object #<error> has no method 'call' 未捕获的TypeError:Object [object object]没有方法&#39;on&#39; - Uncaught TypeError:Object[object object] has no method 'on' 未捕获的typeerror:对象# <object> 没有方法“方法” - Uncaught typeerror: Object #<object> has no method 'method' 未捕获的TypeError:对象没有方法“打开” - Uncaught TypeError: Object has no method 'on' 奇怪的错误:未捕获的TypeError:对象[object HTMLElement]没有方法&#39;getAttribute&#39; - Weird error: Uncaught TypeError: Object [object HTMLElement] has no method 'getAttribute' 未捕获的TypeError:Object# <Object> 没有方法&#39;apply&#39;错误 - Uncaught TypeError: Object #<Object> has no method 'apply' error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM