none
Issue when Changing Scroll Position on Pushpin Click RRS feed

  • Question

  • Hello! I am upgrading a project from Bing Maps v7 to v8. When a pin is clicked, I would like to snap the user down to a certain section of the page. This was working in v7, but after upgrading to v8, in Chrome and Edge, the first time the pushpin is clicked it will jump to the wrong part of the page. On subsequent clicks, it will jump to the appropriate position. (Note, if zoom level is changed then sometimes on the first click after changing zoom level it will once again jump to the wrong position).

    I have tried jumping down via a few different approaches:

    window.location.href = "#jump"; // this worked in the original v7 code
    $(window).scrollTop($("#jump").offset().top);
    $(window).scrollTop(2000);

    All 3 of these approaches has the same effect. A breakpoint reveals that the scroll position is set correctly, but after resuming it scrolls to an incorrect position in both Chrome and Edge (no issue in Firefox). I have tried both adding the event directly to the pin, as well as adding the pin to a layer and adding the click event to the layer instead.

    Any thoughts on why this occurs? Is this a bug, or is there something that I am missing?

    Here is a reproduction of the issue. In this example, when the user clicks the pin, they should expect to be brought down to the text "Jump to here". On Chrome, they are instead jumped up the page the first time they click the pin. On IE, they jump down, but not to the correct position the first time they click the pin. You will need to scroll down to see the map, it is necessary to have some extra content around the map since this is a scrolling related issue:

    https://jsfiddle.net/jaxr4qzh/1/

    Thank you for your time.


    • Edited by Contrecoup Monday, August 7, 2017 9:46 PM fix jsfiddle url
    Monday, August 7, 2017 9:39 PM

Answers