none
How to adjust or set Bing Map Center Offset RRS feed

  • Question

  • Hi,<o:p></o:p>

     

    I am using Bing Map V8 API and showing multiple push pins and setting best view to the map, at that time some of the pins were showing edges of Bing map frame, when I put an infobox on it, the infobox is positioned out of the frame. Is it possible to offset the map let’s say by 50 pixels down when I click on push pin, so my infobox will show correctly on the frame.<o:p></o:p>

     

    Thanks in Advance.<o:p></o:p>

    Gowind

    <o:p></o:p>

    Monday, June 6, 2016 6:51 AM

Answers

  • This hasn't yet been added to the V8 control, however we do plan on adding it later. This feature isn't used very often so it has a lower priority at the moment while we work on building out the rest of the map control and making it stable. We plan to add this after the initial release. It should be available sometime this summer. It is however fairly easy to work around this by doing the following:

    1. Take your center value and convert it to pixels using map.tryLocationToPixel.
    2. Add the offset x/y values to this pixel values x/y properties.
    3. Convert this pixel value into a Location using map.tryPixelToLocation.
    4. Use the new center value to set the center of your map.

    Here is a code sample that offsets the center of the map the same way as V7 did:

    var offset = new Microsoft.Maps.Point(100,-100);
    
    var p = map.tryLocationToPixel(map.getCenter());
    p.x -= offset.x;
    p.y += offset.y;
    map.setView({center: map.tryPixelToLocation(p)});
    Note that in there is a bug in the release branch where the map zooms in when you set the center of the map. This is fixed in the experimental branch which you can use by adding &branch=experimental to the map script URL.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Monday, June 6, 2016 4:29 PM
    • Marked as answer by Gowind_ Tuesday, June 7, 2016 3:06 PM
    Monday, June 6, 2016 4:29 PM
  • That bug was resolved in the August update. Trying again this morning on the release and experimental branches it works fine. The only branch that still has this bug is the frozen branch as that branch is only updated once a year.

    [Blog] [twitter] [LinkedIn]

    Tuesday, January 17, 2017 4:49 PM

All replies

  • This hasn't yet been added to the V8 control, however we do plan on adding it later. This feature isn't used very often so it has a lower priority at the moment while we work on building out the rest of the map control and making it stable. We plan to add this after the initial release. It should be available sometime this summer. It is however fairly easy to work around this by doing the following:

    1. Take your center value and convert it to pixels using map.tryLocationToPixel.
    2. Add the offset x/y values to this pixel values x/y properties.
    3. Convert this pixel value into a Location using map.tryPixelToLocation.
    4. Use the new center value to set the center of your map.

    Here is a code sample that offsets the center of the map the same way as V7 did:

    var offset = new Microsoft.Maps.Point(100,-100);
    
    var p = map.tryLocationToPixel(map.getCenter());
    p.x -= offset.x;
    p.y += offset.y;
    map.setView({center: map.tryPixelToLocation(p)});
    Note that in there is a bug in the release branch where the map zooms in when you set the center of the map. This is fixed in the experimental branch which you can use by adding &branch=experimental to the map script URL.


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Monday, June 6, 2016 4:29 PM
    • Marked as answer by Gowind_ Tuesday, June 7, 2016 3:06 PM
    Monday, June 6, 2016 4:29 PM
  • Do you have any Idea, when the bug fix will be pushed to release branch. I am pointing to experimental branch and  center of the map seems working fine, but not in release branch.
    Monday, January 16, 2017 9:36 PM
  • That bug was resolved in the August update. Trying again this morning on the release and experimental branches it works fine. The only branch that still has this bug is the frozen branch as that branch is only updated once a year.

    [Blog] [twitter] [LinkedIn]

    Tuesday, January 17, 2017 4:49 PM