简体   繁体   English

如何使用jvectormap添加带有系列的标记?

[英]How to add markers with series with jvectormap?

I am trying to add markers to a map. 我正在尝试向地图添加标记。 The markers have values, so each one have different values. 标记具有值,因此每个标记都有不同的值。 I expect that the circles will have different radius depending on these values. 我希望这些值将使圆具有不同的半径。 This is what I do: 这是我的工作:

geochart.removeAllMarkers();
for (var i=0; i<selected_locations.length; i++) {
  loc = selected_locations[i];
  geochart.addMarker(i, locations_data[loc], addedSeries[i] || {}) ;
}

addedSeries is an Array, like [12,0,0,610] addedSeries是一个数组,例如[12,0,0,610]

selected_locations is an Array, like ["11", "12", "5", "2"] selected_locations是一个数组,例如["11", "12", "5", "2"]

locations_data is an Array, like locations_data是一个数组,例如

{
 ...
 "11": {"latLng": [37.89,-4.78], "name": "Location A"},
 "12": {"latLng": [37.18,-3.59], "name": "Location B"},
 ...
}

geochart is a jvm.Map instance. geochartjvm.Map实例。

The current behavior I get is that the markers are being created, but the radius are always the same. 我得到的当前行为是正在创建标记,但是半径始终相同。

Any clue ? 有什么线索吗?

It was easy if you browse the code, but a little tricky. 如果您浏览代码,这很容易,但是有些棘手。 It seems I need to add a list of values, one for each marker type declared on series section of the map . 似乎我需要添加一个值列表,该值列表用于在map series部分上声明的每种标记类型。 This is my map : 这是我的map

var geochart = new jvm.Map({
  container: $('.spain-map'),
  map: 'es_mill_en',
  markers: markers,
  series: {
    markers: [{
      attribute: 'r',
      scale: [5, 20],
      values: [...]
    },{
      attribute: 'fill',
      scale: ['#00CC00', '#CC0000'],
      values: [...]
    }]
  }
});

So this is how I resolve it: 所以这就是我解决的方法:

geochart.addMarker(i, 
                   locations_data[loc], 
                   [ addedSeries[i], addedSeries[i] ] || {}
                   );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM