简体   繁体   中英

jvectormap marker color problems

I'm trying to use jvectormap to create a map of the US with markers. 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.

I've tried using the old jvectormap but it appears it is buggy and doesn't show the markers in the correct locations.

Here is an example of two different types of markers based on a third element in the list of markers called 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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