highcharts / map-collection-dist

Other
31 stars 36 forks source link

World map: Taiwan as a part of China #90

Open windyboyy opened 3 years ago

windyboyy commented 3 years ago

@highcharts/map-collection/custom/world

KacperMadej commented 3 years ago

Hi @a2017218057

Support how?

Taiwan is on the map.

image

windyboyy commented 3 years ago

Hi @a2017218057

Support how?

Taiwan is on the map.

image

when I touched China with the mouse, Taiwan did not light up, but it should light up

windyboyy commented 3 years ago

@KacperMadej when I touched China with the mouse, Taiwan did not light up, but it should light up

KacperMadej commented 3 years ago

If you want to merge together multiple map features on any map you could edit the source file of the map and manually copy the feature's geometry into another. For example, let's merge China into Taiwan, so when you hover over China or Taiwan it will highlight both map features (as is your requested functionality if I understand you correctly): https://jsfiddle.net/BlackLabel/5ok3e42y/

In general, to merge together any map features you could use a code like below:

let cn;
Highcharts.maps['custom/world'].features.forEach((f, i)=>{
    if (f.id === 'CN') {
        cn = f.geometry.coordinates;
        Highcharts.maps['custom/world'].features.splice(i, 1);
    } else if (f.id === 'TW') {
        f.geometry.type = 'MultiPolygon';
        f.geometry.coordinates = [f.geometry.coordinates, ...cn];
        delete f.properties['hc-middle-x'];
        delete f.properties['hc-middle-y'];
        f.properties.name = 'China';
    }
});

In the above code example, the features are modified on the client-side, and for better performance, it should run once and generate a new file that could be later loaded instead of the original map file. In practice, the difference in performance is insignificant.

For changes to be applied to the map collection maps I believe we should have a good reason and so far you have not given any - please elaborate or the issue will be closed.

windyboyy commented 3 years ago

@KacperMadej emmm, because of i'm in china , i can not open this link(https://jsfiddle.net/BlackLabel/5ok3e42y/), could you provide an example in codepen?

KacperMadej commented 3 years ago

https://codepen.io/Blacklabel/pen/porQRLv