jvectormap markers

戏子无情 提交于 2019-12-24 05:01:06

问题


I'm using jvectormap to show the locations of alumni related to the business I work with. Is there a solution to add links to markers? By that I mean for each individual marker, I am aware you can use this code to link all markers to one URL (as an example):

 onMarkerClick: function (event, code){
   var url = "http://www.google.com";
   $(location).attr('href',url);
 },

I've arranged my markers like this: "US": {latLng: [38.90, -98.45], name: 'United States of America'}, if this makes any difference.

I'm looking to use a unique URL for each marker. So USA links to a page dedicated for the USA for example. Currently I am able to link all markers to a single URL using the above code, it's when I try doing more than one country that I run into issues.

Thanks in advance,

Tom.


回答1:


You can do this

onMarkerSelected: function(){
   // do what you need to do here.
}

Example is here: http://jvectormap.com/examples/regions-selection/

In your marker add the URL:

"US": {latLng: [38.90, -98.45], name: 'United States of America', weburl : "/blah/foo"}

then when you have your function:

onMarkerClick: function(events, index) {
    $(location).attr('href', markers[index].weburl);
}

markers being your array of markers.



来源:https://stackoverflow.com/questions/14733360/jvectormap-markers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!