Bing Map CSS position:fixed InfoBox issues - javascript

I have a map that is position:fixed on my page. So when I scroll down it stays with you on the page When I roll over the pinpoints on my map the InfoBox displays in the correct position, but when I click one of my results which triggers the Infobox to display it is relative to where the map was when the page loaded (so usually high up on the page and not down where I scrolled it). I am trying to manipulate where the info box displays using the ShowInfoBox, but it always needs LatLong Coordinates instead of pixel coordinates. Since the map moves up and down the page the pixel location could change depending on how far you scroll.
Right now I am just poitioning it with javascript after it loads but that is a less then ideal situation as I run into all sorts of problems.

It's probably a bug with Bing Maps that it doesn't position the infobox correctly. You'll have to work around it. The infobox most likely has a unique ID or a unique class that you could select. Using that you can manipulate the infobox once you set the new Lat/Long position.
When you display the infobox, after you call the show method with the Lat/Long you should then reposition the infobox using CSS based on the scroll positon. So, if the page has scrolled down 100 pixels you need to add 100 pixels to the "top" css property. The same goes for the "left" property. This should always result in your infobox appearing in the correct place.

Related

How to show a marker tooltip that can overflow the map container?

In my map, I have to show some markers that have relatively large tooltips attached to them (a div with roughly 100x200px). The map container itself is about 350px in height, so you very often run into situations where your tooltips are cut off at the map borders.
From what I can see, the map container has overflow: hidden; set in its CSS, which is because of the way the tiles get shown (they move "under" the container). When I set the overflow to visible, it seems to work, but then the map floods the page.
Is there a plugin or some best practice to achieve the desired behaviour without completely changing leaflet under the hood?
Here is a possible solution, instead of appending the tootip to the map container, append it as the last child of document.body then just call getBoundingClientRect() on the marker DOM node on hover or on click and use it to position the tootip next to your marker node. That way, your tootip won't be constrained by the size of the map container.

Issue in infobox repositioning in Bing map v7

I am using the Bing map version 7 for the displaying the events and its details on map. For that i have added the following reference js file "http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&mkt=de"
I have implemented the displaying the event pin on map and displaying the event details in infobox. I am stuck up with displaying event details in infobox which are on the boundary of the map. This infobox goes outside the map.
I have found on solution in the post
Cool Infobox and plot polygons through xml ....in bing maps , pure javascript
But even after implementing the solution mentioned(CustomInfoboxModule) in above link, i am facing the issue for the events having more details.
Check for the
Not 100% sure if I understand the question. Is your issue that the infobox falls outside of the map? If so, if you make your Infobox big enough this is bound to happen. There are a couple of solutions:
Limit the size of your description area (i.e. give it a max-height) and make it scrollable (i.e. overflow-y: auto). This will ensure that your infobox never exceeds a certain height. The custom infobox control you are using, positions the infobox based on which quadrant the pushpin is in. If the pushpin is in the top left corner the infobox is shown to the right and down. If the pushpin is in the bottom right corner the infobox is shown to the left and up. This means that if you ensure that the max height of the infobox is half the height of the map, that it should always be displayed within the map.
Alternatively, if you know the infobox will never be bigger than the height of the map, you could simply reposition the map so that the pushpin is higher and then open the infobox.

Translating Google Street View POV to absolute browser positions. (CSS left, top)

I currently have a Google Street View Panorama from the API loaded into a DIV as described here: https://developers.google.com/maps/documentation/javascript/streetview
I'm currently able to get the heading and pitch from the pov_changed event with panorama.getPov().
I want to have a DIV on top of the panorama (with a higher z-index) and absolute-position it using css left and top to always be at same point in the panorama.
I'm not sure how to translate from panorama.getPov().heading and panorama.getPov().pitch to the left and top values for the overlay DIV.
I guess I need to take into account the window width/height, zoom, pitch and heading, but I can't still figure out how to get the right values.
Any ideas or suggestions?

In leaflet, how to set a marker to a fixed position on map?

For example, I want to set a leaflet marker always pin to the bottom-right corner of the leaflet map.
Does anyone have ideas about this?
There are a couple of ways to approach this, depending on what you want to accomplish.
This request for a centered "floating" crosshairs icon sounds very similar to your request. You essentially use getCenter() to create a fixed reference point, then use setLatLng() to update your marker's location relative to the map's center each time the user pans.
If the point you'd like to pin is purely cosmetic, you could just use HTML and CSS to position it on the page. This example, which is also referenced in the previous example, uses CSS to position an icon within a span as a visual reference point, then takes advantage of getCenter() to add lat/lon values to the form on the left of the page.
You can make use of getCenter(), getSize(), and L.marker() to pin to the bottom-right.
Reference: http://leafletjs.com/reference.html

Prevent browser moving element when children are focused

I am implementing a simple map. The map consists of a viewport, and the map image itself, which is actually a div with a background image.
The viewport is relatively positioned and it's overflow is hidden, and the map image is absolutely positioned within the viewport.
The map can be moved with the mouse within the viewport and the map can also be zoomed (just increasing the size of the image as the image is a .svg)
The map has points on it which the user can hover over to get a description in a tooltip of the point. The points can also be focused by tabbing to them.
Points are children of the map image div and are absolutely positioned by percentage (to retain the correct position when the map is zoomed)
When a point is focused, I want to move the map so that the point is in the middle of the viewport. I have written the code for this and it works fine. However, if a point is outside of the viewport (not visible) then the browser automatically tries to move the map so the point is visible. I don't want it to do this, as it is interfering with the code I have written to animate the map move. This is nothing to do with scrolling.
I am using jQuery and have tried e.preventDefault() and return false; in the focus handler for the map points but neither work.
Is preventing this behaviour even possible?
Thanks in advance
I have found out that the scroll value of the map viewport was being set by the browser in order to bring the map point into view. As I am moving the map by setting it's top and left positions, this is what was causing the issue.
The solution was to add the .scroll() event listener to the viewport and just set the scrollTop and scrollLeft values to 0 when the event is triggered

Categories

Resources