patrick.bastien
Posts: 1
Joined: Tue Nov 02, 2021 10:55 am

Zoom in on a country when the id is set

Hi Highcharts Support,

I have been trying to figure out the proper code for this via Stackoverflow examples but nothing is working for me and I'm fairly new to coding in Javascript. Please take a look at the example I created in jsfiddle.net below:



https://jsfiddle.net/patriciob/jarkLt6z/



I want to be able to zoom in to a country using the "id" of that country but the code I found online doesn't really work, I want to modify the following section of the code:

Code: Select all


//Zoom to the point that equals the country id after the user has clicked on the country in the spreadsheet
			setTimeout(function() {
	  			chart.update({
	    				series: [{
	      					data: data,
	    					}]
	  					}, true, false, false);
					if (params[5]) {
        	
        				chart.get(params[5]).zoomTo();
					    chart.mapZoom(0.125);
					    console.log();
       					
					}
			}, 1000);



At this point being able to Zoom in on a particular country would allow me to set up a link in a Jedox report so when a person clicks a country's name in the spreadsheet the link would update the widget and the Highcharts map would zoom in to the correct country.



Any JavaScript-based examples you can send my way would be greatly appreciated.



My Very Best,

Patrick B.
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Zoom in on a country when the id is set

Hello Patric,

Welcome to our forum and thanks for contacting us with your question!

The 'mappoint' type does not have a zoomTo() method, this is a bug that has already been reported. You can get around this by adding the country you want to zoom to the 'Basemap' series.

In addition, in the latest version of Highmaps 9.3 there was a problem with the positioning of points during zooming, so at the moment it is best to use version 9.2.2 in this case. (http://code.highcharts.com/maps/9.2.2/highmaps.src.js)

Demo: http://jsfiddle.net/BlackLabel/qsy1fLue/

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Maps”