未捕获类型错误:对象的翻译:具有文件y错误没有方法'X' [英] Uncaught TypeError: Object[object Object] has no method 'x' at file y Error
问题描述
我使用的传单在Android和我试图表现出警惕编辑的坐标。
I'm using LeafLet in Android and I'm trying to show edited coordinates in alert.
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>
下面是我的功能
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
});
});
当我尝试这对网络浏览器,它是工作好。但是当我尝试这在Android中,我得到这个错误。
When i try this on web browser, it is working good.. But when I try this in Android, I'm getting this error.
任何建议?
16 10-18:22:05.240:E / Web控制台(4459):未捕获类型错误:对象的翻译:具有在文件中没有方法'getLatLngs':///android_asset/www/main.html :114
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
推荐答案
安迪感谢解决方案,但它不是错字。结果
如果您是标记工作,你必须使用 getLatLng()的功能,因为标记只有一个经纬度。结果
如果你正在使用的比 1点状多边形,折线越多,你必须使用 getLatLngs()功能。我与标记工作,我试图用getLatLngs()与标记。这是问题
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.
If you are working with more than 1 point like polygon, polyline, you have to use getLatLngs() function. I was working with Marker and i was trying to use getLatLngs() with Marker. That was the problem
这篇关于未捕获类型错误:对象的翻译:具有文件y错误没有方法'X'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!