map-collection-dist icon indicating copy to clipboard operation
map-collection-dist copied to clipboard

World map: Taiwan as a part of China

Open windyboyy opened this issue 4 years ago • 6 comments

@highcharts/map-collection/custom/world

windyboyy avatar Oct 28 '21 09:10 windyboyy

Hi @a2017218057

Support how?

Taiwan is on the map.

image

KacperMadej avatar Oct 28 '21 17:10 KacperMadej

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 avatar Oct 28 '21 17:10 windyboyy

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

windyboyy avatar Oct 28 '21 17:10 windyboyy

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.

KacperMadej avatar Nov 01 '21 09:11 KacperMadej

@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?

windyboyy avatar Nov 02 '21 03:11 windyboyy

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

KacperMadej avatar Nov 15 '21 16:11 KacperMadej