0

enter image description herecurrently I have a map of the globe and when I try panning on the map after zooming in on the countries, it resets the zoom to the default zoom. I am able to pan the globe but I cannot pan when I am zoomed in. It makes navigating a bit annoying. Here is my current code:

 Highcharts.getJSON(
  'https://code.highcharts.com/mapdata/custom/world.topo.json',
  topology => {
 
    const chart = Highcharts.mapChart('container', {
      chart: 
      {
        map: topology,
      },
 
      title: {
        text: ''
      },
 
      legend: {
         enabled: false,
         align: 'center',
         verticalAlign: 'bottom',
         itemStyle: {
             fontWeight: 'bold',
             fontSize: '20px'
         }
     },
 
      mapNavigation: {
        enabled: true,
        enableDoubleClickZoomTo: true,
        buttonOptions: {
          align: 'right',
          verticalAlign: 'bottom'
        }
      },
 
      mapView: {
        maxZoom: 30,
        projection: {
          name: 'Orthographic',
          rotation: [60, -30]
        }
      },
 
      colorAxis: {
                         min: 0,
                         max: 100,
                         text: '',
                         stops: [[0, 'darkgray', ''], [0, '#5ce1e6', '{{question['answer1']}}'], [0.49, '#c9f5f7', ''], [.50, '#aee0a0', ''], [.51, '#fff4c8', ''], [1, '#ffde59', '{{question['answer2']}}']],
                         title: {
                          text: '',
                          },
                     },
      credits: {
        enabled: false
      },

      tooltip: {
        borderColor: 'none',
        borderRadius: 10,
        useHTML: true,
        formatter: function(tooltip) {
            return `<b>${this.point.name}</b> <br> <div style="display: inline-block;" class="square-answer1-globe"></div>{{question["answer1"]}}: <b>${this.point.value1}</b>% <br> <div style="display: inline-block;" class="square-answer2-globe"></div>{{question["answer2"]}}: <b>${this.point.value2}</b> %`
        },
        backgroundColor: 'black',
        style: {
        color: 'white'
    },                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
     },


      plotOptions: {
        series: {
          animation: {
            duration: 750
            
          },
          clip: false
        }
      },
 
      mapline: {
  color: 'black' // change to the desired color
},
        series: [{ 
           name: 'Graticule',
           id: 'graticule',
           type: 'mapline',
           data: getGraticule(),
           nullColor: 'gray',
           color: 'black',
           
           accessibility: {
          enabled: false
        },
        enableMouseTracking: false
         },
        
      
      {
        data: data1,
        joinBy: 'name',
        borderWidth: 0.5, // Set the border width
        borderColor: 'black', // Set the border color
        name: '',
        states: {
          hover: {
             color: '', // set to same color as regular state
            borderColor: '#000000'
          }
        },
     
        accessibility: {
          exposeAsGroupOnly: true
        }
      }]
    });


    // Render a circle filled with a radial gradient behind the globe to
    // make it appear as the sea around the continents
    const renderSea = () => {
      let verb = 'animate';
      if (!chart.sea) {
        chart.sea = chart.renderer
          .circle()
          .attr({
            fill: {
              radialGradient: {
                cx: 0.4,
                cy: 0.4,
                r: 1
              },
              stops: [
                [0, 'white'],
                [0.5, 'white']
              ]
            },
            zIndex: -1
            
          })
          .add(chart.get('graticule').group);
        verb = 'attr';
      }
 
      const bounds = chart.get('graticule').bounds,
        p1 = chart.mapView.projectedUnitsToPixels({
          x: bounds.x1,
          y: bounds.y1
        }),
        p2 = chart.mapView.projectedUnitsToPixels({
          x: bounds.x2,
          y: bounds.y2
        });
      chart.sea[verb]({
        cx: (p1.x + p2.x) / 2,
        cy: (p1.y + p2.y) / 2,
        r: Math.min(p2.x - p1.x, p1.y - p2.y) / 2
      });
    };
    renderSea();
    Highcharts.addEvent(chart, 'redraw', renderSea);
 
  }
 );

I tried this:

chart: {
        type: 'orthographic',
        panning: true
    },
    mapNavigation: {
        enableMouseWheelZoom: true
    },

But it still zooms out when panning.

I tried this:

chart: {
    map: topology,
    events: {
      // Prevent resetting the zoom on map panning
      wheel: function (e) {
        e.preventDefault();
        var chart = this;
        setTimeout(function () {
          chart.pointer.zoomHorizontally = false;
        }, 1);
      }
    }
  },

But that doesnt do anything related to this either.

  • Hi, I reported the bug, which you can track here: https://github.com/highcharts/highcharts/issues/18542 . Until the problem is solved, you can use the last working version of Highcharts (10.1.0) – magdalena Feb 20 '23 at 18:27
  • Thank you so much, its working as expected now! – Gavan Sarrafian Feb 20 '23 at 23:58
  • I noticed the map seems to bounce when you start panning. Do you know if this is part of the bug or if it can be modified to be more precise when panning? One last thing I also was having trouble with was related to zooming out on mobile. Zooming in with two fingers is very responsive, but zooming out by pinching the screen does not zoom out quickly so you have to opt to use the zooming buttons instead which can be a bit tedious. Let me know if you have any ideas on these other issues, thanks!!! – Gavan Sarrafian Feb 21 '23 at 00:42
  • This happens when the map zooms and is no longer centered, the bounce occurs when panning to recenter the map. Is there a way to keep the map centric while zooming? – Gavan Sarrafian Feb 21 '23 at 02:08
  • Thanks for reporting! The bouncing seems to be part of the bug as well. When it comes to mobile zooming, I'm not sure If I quite understand the issue. Could you please reproduce it, and provide a screen record showing this behavior? – magdalena Feb 21 '23 at 16:45
  • https://mail.google.com/mail/u/0?ui=2&ik=9faee26ba7&attid=0.1&permmsgid=msg-f:1758469992630002222&th=186757243ae5222e&view=att&disp=safe Let me know if you can review this video! As you will find, zooming in is sensitive (in a good way) and allows zooming to be easy with two fingers, but zooming out takes a lot longer and doesnt seem to work properly. – Gavan Sarrafian Feb 21 '23 at 19:28
  • Thank you for providing the link, but unfortunately, I'm not able to open it. Is it possible for you to share it as a .gif or use another host? – magdalena Feb 22 '23 at 10:12
  • Hey! I have added a gif to the beginning of my original post up top. Hopefully it's clear. To recap the issue: When I zoom into the map, it zooms quickly and as expected. When I try zooming out, it takes multiple pinches on my mobile device to zoom out. Maybe there is a function to increase zoom sensitivity when zooming out? Thanks in advance! – Gavan Sarrafian Feb 23 '23 at 00:56
  • Hi, thank you for providing the gif. Unfortunately, it was marked as bug of the mapline series https://github.com/highcharts/highcharts/issues/18572 . As a temporary solution - If it is not necessary for your project - I can only recommend removing the glob grid which is built based on the mapline series. – magdalena Feb 24 '23 at 19:58

0 Answers0