问题
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