Smooth update google maps overlay - javascript

My problem is I need to have a very custom marker to show the users location and I'm using this method to create. However my marker isn't stationary and I need to redraw it once user location changes.
Currently I've tried removing the overlay from the map using OverLayName.setMap(null); and removing the dom element with javascript, but both ways I get a flicking effect of the marker being removed from the map and added, which isn't smooth.
Is there a way to move the overlay on the map without it being removed and being drawn again ? Or maybe there is a way to create a smooth redraw visualization with css ?
Cheers guys.

Related

Disable dragging of polyline while allowing other layer to drag in leaflet.js

I am creating map overlaying multiple png file using Leaflet.js.
I want to overlay polyline on top of these map disabling polyline to move.
The behavior I expect is following.
User can drag the map which is composed by png file. While map is being dragged, polyline doesn't move.
How can I achieve this behavior?
If you have a reference to the polyline
var polyline = L.polyline(...);
Then you can use
map.addLayer(polyline);//For show
map.removeLayer(polyline);// For hide
at the moment I think there is no native method to only hide/show, maybe in the 0.7 version
Other solution is to access to the object container, in a old commet from the maintainer
I don't think there's an easy solution, for tile layers at least. :( I'll try to handle this sooner.
For vectors, you can change path._container.style.display, and for markers - marker._image.style.display and marker._shadow.style.display.

Persistent layers after style change in Mapbox gl js

Is it possible to change map style from Streetview to satellite retaining all manually drawn layers (geojson shapes)?
e.g.
Let's say we have a circle on Streetview map and want to show the same circle in street view mode. After we change map style to satellite we have to add the circle again. Is there any possibility to avoid that?
I want to find the possibility do not process something that was processed already again, to exclude listening for style changes and adding layers again.
Is any multi styles map instances supported by mapbox?
Or the possibility to render the whole style as a background or might be even having Streetview as a layer in my main style to achieve that?
Check out https://github.com/mapbox/mapbox-gl-js/issues/4006 for a few ideas of how this could be made easier along with some workarounds.

Need help regarding Mapbox markers

I am using mapbox and I am trying to hide a marker until the building itself is clicked using JS. I've tried setting event listeners on my whole map but it will only pop up if the exact coordinates are clicked. Because a building can be of varied size, how would I implement a click function that makes the marker appear when an actual building is clicked and not the coordinates?

Place a draggable image above marker in google maps

Is there a way to do this? I've got markers placed on the map, but above it, I want to add an image, that looks exactly like the marker, that I can drag. I want to achieve effect that I drag the image to the defined place simultaneously the marker will still stay there so I'm actually operating with copy of this marker.
Thanks.

Custom InfoWindow size/pointer position in Google Maps API

I have a map application that can be seen here:
http://chrismcaleenan.com/map/?page_id=25
Each of the Malaysian states in the application will have an InfoWindow that displays additional information. You can see an example of this by mousing over 'Kedah' either in the main data table on the right or on the state itself in the map.
The problem, as you can see, is that the map pans in order to position the InfoWindow. Is there a way to fix the map position and set the InfoWindow size or position so that it is fully displayed without panning? In the Kedah example, one could have the InfoWindow positioned directly to the right and/or use a shorter tail.
One option would be to create a custom graphic for each state, but I'd rather avoid this as I will be running into the same issue with add'l data (e.g. click Kedah to zoom - will have InfoWindows on all data points on zoom).
If you're playing around double-clicking the water will zoom back out and reset map.
Thanks!
Yes, and sometimes the pan pulls the mouse outside of the state, which causes the InfoWindow to disappear. I know that's not what you want. The Google Maps demo catalog includes a sample that I think will give you what you want for your map. It's named SmartInfoWindow. Take a look, click on some of the markers, check out how the SmartInfoWindow behaves, and see if that might help you achieve what you want. It's not perfect, but it keeps the pan at the absolute minimum.

Categories