Google Maps API v3 currently supports two types of animation for markers: DROP and BOUNCE
Is there a way I can speed up the BOUNCE or slow down the DROP animation?
Google Maps API doesn't support animation properties or customization, just the ability to select "drop" or "bounce" as you said.
It should be possible to apply custom animations to marker elements through jQuery or other framework. Alternatively you could supply an animated GIF as a marker.
Related
I'm making an experiment with map animation. For now, I only use OpenLayers 6. I want to implement Google Maps as well.
The idea is to animate map interactions such as pan and zoom. Those animations need to be of a fixed duration. In OpenLayers, I'm using the handy view method animate() that way (variables can change depending on the context):
map.getView().animate({
center: [newx, newy],
zoom: newzoom,
easing: oleasing,
duration: durationms
})
I was wondering if there was any Google Maps equivalent. For now, I'm only looking for a way to animate a pan or a zoom with a fixed duration value.
I know there are the Maps methods panTo() and setZoom() but I cannot set a specific duration.
moveCamera works without animation, so you could program your own animation sequence using JavaScript timeouts - or even synchronize your Google map with the change:center and change:resolution events of a hidden OpenLayers view.
For example https://jsfiddle.net/r7kuge1y/ which applies OpenLayers animation from https://openlayers.org/en/latest/examples/animation.html to a Google map example from https://developers.google.com/maps/documentation/javascript/adding-a-google-map
Hi I am using the code here http://rominirani.com/html5-recipes-more-on-geolocation/ to implement a user tracking app built in HTML5.
The issue I have is that whenever I move, the map completely re-renders. Is there a way to just update the marker position and set the center of the map to that position or is there a better way to implement Google maps with a marker that moves when the user moves?
Thanks
You can combine the HTML5 geolocation API with Google Maps to add/remove a marker on a position change listener
navigator.geolocation.watchPosition
https://google-developers.appspot.com/maps/documentation/javascript/examples/overlay-remove
I am trying to make a Polyline editor, just like the one from Google Drawings Library. (for specific reasons, i can't use that one)
It works on the same principle. Start with a point, then for each click add new points and make the polyline.
On the editor from Google Drawings Library, while you are editing a polyline, you're mouse can't interact with other items from the map.
Inspecting with firebug, i see that they have an overlay of 20000000 z-index inside the map.
Is there any way of creating the same overlay for my map using default Google Maps functions?
It's a custom overlay inside the overlayMouseTarget-pane with the same size as the map and a draw-method that updates the position of the overlay. You may do the same.
I am making an application with google maps.
When markers are overlapping only the last one is displayed even if the icons are different..
I do not want it to cluster in that case, rather it should show both maybe by changing the coordinates just a but??
Any solutions??
I think this is a pretty elegant solution, called Spiderfying the markers.
https://github.com/jawj/OverlappingMarkerSpiderfier
I'm thinking of using it.
What I do now is use JavaScript to make a fancy popup that hides and shows divs on one marker location (created problematically in PHP, but you could do it on JS too). It has the side benefit of allowing less markers on the map.
Click a black numbered marker on this map to see it in action.
http://www.yourmapper.com/map/111/crime-reports/crime-in-metro-louisville-ky-since-jan-2003.htm
Another option is to use Google Maps API 3 Utility Library, it has a Marker Clusterer.
When clicking from one marker to another in Google Maps, the map screen animates the move smoothly if both markers are within them initial map view but jumps if one of the markers is off screen.
I'm trying to set up a map which has several locations within the main map area but has one which is 'off screen'. I have a signpost icon to the more distant location within the initial map area which I want to smoothly scroll to the off screen location when clicked (so as to give a better sense of it's relative location). I can't find anything in the Maps API which would let me do this however.
I could zoom out, move and then zoom in again but this looks a bit jarring. Am I missing something in the API, or does anyone have any suggestions?
Unfortunately, I don't think this is possible (without a change from Google). From the v3 API reference for panTo:
Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.
which implies that if that change is not less than the dimensions of the map, the transition won't be smoothly animated. The other pan methods are similar.
You could try moving in multiple steps but that's a bit of a hack and I suspect the result will be poor.
Sorry that's not very helpful (I have the same problem).
For me this method works, but i'm using Google Maps API v2.
LatLng latLng = new LatLng(lat,lng);
map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, ZOOM_FACTOR));
This animates the camera from current position to the new one.
If you are using Gmaps API V2, then you can implement smooth animated move very easily by using panBy() method. You have to use fromLatLngToContainerPixel() method to find the amount of pixels to pan by.
Here is the bit of code:
var newLoc = map.fromLatLngToContainerPixel(new GLatLng(lat, lng));
map.panBy(new GSize( newLoc.x, newLoc.y ));
However, what I am trying to do is to achieve the same thing in maps API V3, but sadly fromLatLngToContainerPixel() method does not work anymore the way it did :(