简体   繁体   English

jvectormap 标记颜色问题

[英]jvectormap marker color problems

I'm trying to use jvectormap to create a map of the US with markers.我正在尝试使用 jvectormap 创建带有标记的美国地图。 I want these markers to either be red or blue and I would like to specify which color goes to which marker manually (not using any sort of scale or overly complicated data visualization function).我希望这些标记是红色或蓝色,我想手动指定哪种颜色适合哪个标记(不使用任何类型的比例或过于复杂的数据可视化功能)。 Is there a way to do this?有没有办法做到这一点? The new jvectormap's API is way too abstract for me to easily implement this.新的 jvectormap 的 API 对我来说太抽象了,无法轻松实现。

I've tried using the old jvectormap but it appears it is buggy and doesn't show the markers in the correct locations.我试过使用旧的 jvectormap,但它似乎有问题,并且没有在正确的位置显示标记。

Here is an example of two different types of markers based on a third element in the list of markers called type . 是基于标记列表中名为type的第三个元素的两种不同类型标记的示例。 I essentially created another array called colors used for the values in the data series representation.我基本上创建了另一个称为颜色的数组,用于数据系列表示中的值。 The loop right before the map is created iterates through the list of markers and pulls out the type and decides what the color value should be based on the type .在地图前,回路权利是通过标记和拉出的列表中创建迭代并决定什么颜色值应根据类型

for (var i = 0; i < markers.length; i++) {
    if (markers[i].type == 'call-center') {
        colors[i] = 0;
    }
    else {
        colors[i] = 1;
    };
};

Similar setups can be achieved for different types if you add additional if statements.如果添加额外的if语句,可以为不同类型实现类似设置。

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

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