none
Stop Map From Recentering When Adding Layer RRS feed

  • Question

  • I have a v8 map embedded in a website, and I'm loading some toggle-able sets of pins from some XML files.

    Some information on this can be found here on this resolved issue: https://social.msdn.microsoft.com/Forums/en-US/5339e710-bae5-4f93-9c31-446742ea3f3f/infobox-from-geoxml-with-html-formatting . So as the layers are toggled and the pins are loaded, the map will realign itself to center around the last loaded sets of pins.

    For example, one set of pins spreads across the US and is "on".  When another set of pins is enabled that is mostly int he sourth west US, the map realigns around these pins and centers in on say, New Mexico.  A third set of pins may center the map down on Florida because the pins are all located in this region.

    I am wondering how to stop this behavior.  Ideally, the map will simply stay stationary to whatever position and zoom level the user is currently on.  I would be find with the map simply re-centering to the default view around the US.


    Josh Miller


    • Edited by JoshMiller Thursday, November 9, 2017 5:38 PM
    Thursday, November 9, 2017 5:37 PM

Answers

  • There isn't an option for this yet, but will be one soon. The team is adding an autoUpdateMapView option for GeoXmlLayers which, when set to false will disable the automatic map view change. For example:

    Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', function () {
        var layer = new Microsoft.Maps.GeoXmlLayer('https://bingmapsv8samples.azurewebsites.net/Common/data/kml/SampleKml.kml', null, { autoUpdateMapView: false });
        map.layers.insert(layer);
    });

    This should be in the experimental branch in the next few weeks and in the main release branch in January. Alternatively, if you can use the GeoXml.read function and get the raw data, then have full control over the rendering. For example: http://bingmapsv8samples.azurewebsites.net/#GeoXml%20-%20Read%20from%20Url


    [Blog] [twitter] [LinkedIn]

    Friday, November 10, 2017 1:39 AM

All replies

  • There isn't an option for this yet, but will be one soon. The team is adding an autoUpdateMapView option for GeoXmlLayers which, when set to false will disable the automatic map view change. For example:

    Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', function () {
        var layer = new Microsoft.Maps.GeoXmlLayer('https://bingmapsv8samples.azurewebsites.net/Common/data/kml/SampleKml.kml', null, { autoUpdateMapView: false });
        map.layers.insert(layer);
    });

    This should be in the experimental branch in the next few weeks and in the main release branch in January. Alternatively, if you can use the GeoXml.read function and get the raw data, then have full control over the rendering. For example: http://bingmapsv8samples.azurewebsites.net/#GeoXml%20-%20Read%20from%20Url


    [Blog] [twitter] [LinkedIn]

    Friday, November 10, 2017 1:39 AM
  • Thanks, I'll keep an eye out for the update,

    Josh Miller

    Friday, November 10, 2017 4:01 PM