javascript - jvectormaps customize onMarkerClick -


i'm drawing map using jvectormaps, user clicks on marker have alert triggering.

i'd able add custom item within markers array serve record id. can modify alert(id); line in code below accesses current marker's id?

here entire script:

$(function(){   var markers = [         {id: 1, latlng: [33.44838, -112.07404], name: 'phoenix, az', style: {r: 12, fill: '#76c043'}},         {id: 2, latlng: [39.73924, -104.99025], name: 'denver, co', style: {r: 30, fill: '#ffdd85'}},         {id: 3, latlng: [37.33821, -121.88633], name: 'san jose, ca', style: {r: 30, fill: '#f58a78'}}       ];    var map = new jvm.map({     container: $('.map'),     map: 'us_aea_en',     labels: {       regions: {         render: function(code){           var donotshow = ['us-ri', 'us-dc'];            if (donotshow.indexof(code) === -1) {             return code.split('-')[1];           }         },         offsets: function(code){           return {             'ca': [-10, 10],             'id': [0, 40],             'ok': [25, 0],             'la': [-20, 0],             'fl': [45, 0],             'ky': [10, 5],             'va': [15, 5],             'mi': [30, 30],             'ak': [50, -25],             'hi': [25, 50]           }[code.split('-')[1]];         }       }     },     backgroundcolor:'#d3d3d3',     zoombuttons:false,     markers: markers,     regionsselectable: false,     markersselectable: false,     markersselectableone: false,     onmarkerclick: function(event, id){       alert(id);     },          onregionlabelshow: function (e, el, code) {                  e.preventdefault();          }   }); }); 

i added in id: 1, id:2, id:3 pieces in markers array, need accessing it.

just access markers local variable local id:

onmarkerclick: function(event, id){   alert(markers[id].id); }, 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -