[英]How do i get the name or identification of a marker JVectorMap
How do I know the name
or id
of the marker that is clicked? 我怎么知道被点击的标记的
name
或id
?
And is it possible? 有可能吗?
Is there a way to find the label/name
of the marker like this for example: 有没有办法找到
label/name
,例如:
onMarkerClick: function(label){
alert(label.text());
}
All help appreciated :) 所有帮助表示赞赏:)
The second parameter in the click handler function is the key/index of the marker object. 单击处理程序函数中的第二个参数是标记对象的键/索引。
onMarkerClick (Event e, String code)
onMarkerClick(事件e,字符串代码)
One possible way to do that, is: 一种可行的方法是:
onMarkerClick: function(e, code) {
var mapObj = $("#map").vectorMap("get", "mapObject");
var idx = parseInt(code); // optional
var name = mapObj.markers[idx].config.name;
var latitude = mapObj.markers[idx].config.latLng[0];
var longitude = mapObj.markers[idx].config.latLng[1];
}
Explanation: 说明:
name
and the coords
of the point name
和coords
If you need more info, try to explore the properties of the map object in the browser, like this: console.log(mapObj.markers);
如果需要更多信息,请尝试在浏览器中浏览地图对象的属性,如下所示:
console.log(mapObj.markers);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.