none
Map element not taking into account body elements left margin RRS feed

  • Question

  • I'm running into strange issue when using bing maps. I'm able to add pushpins, polygons, images, etc. to the map and they show up in the correct geospatial location. However, the outline for the click events is offset to the left, i.e. if I want to click or drag a pushpin, for example, I need to click roughly 200 pixels to the left. After some investigation I noticed that my body element has a left margin of 185px (to make room for our left menu) and if I go into the map element and change the "left" css value for the child element with id "labelCanvasId" 185 more pixels to the left, everything lines up correctly. 

    It's pretty clear that when bing loads and creates the canvas, is it not taking into account the left margin of the body tag. Has anyone come across this issue? And if so, how were you able to handle it. I was thinking about adding a handler for the view change event and forcefully adding the offset but there must be a better way. Any help is appreciated.

    Friday, December 22, 2017 5:00 PM

Answers

  • Adding a margin to the body of an HTML page is highly unusual with the exception of margin:0. Every single web app I've ever come across that wants to margin the content, wraps the content in a div and sets the margin on there. 

    [Blog] [twitter] [LinkedIn]

    Thursday, December 28, 2017 8:08 PM

All replies

  • Adding a margin to the body of an HTML page is highly unusual with the exception of margin:0. Every single web app I've ever come across that wants to margin the content, wraps the content in a div and sets the margin on there. 

    [Blog] [twitter] [LinkedIn]

    Thursday, December 28, 2017 8:08 PM
  • Yes, it was easy enough to fix. All I need to do was wrap our content into a div.
    Wednesday, January 3, 2018 4:02 PM