I have a mapbox project that I need to be able to re-center the map when a popup closes. Right now, clicking a marker will pan the map and after the user closes the popup they are left with the map panned over to the new location. I simply need the map to recenter to the original location I set as my map center.
I've not found a method using the mapbox api so I don't have any code to start. I'm more looking for someone who might have experience with such a configuration.
Since mapbox.js is built on top of leaflet you can use the Leaflet API.
You can listen for popupclose events. Then you can call map.setView() and center the map at the original position.
Here is a working example
Related
google_maps_flutter, how not to start image from bottom?
By default, the marker appears directly above the coordinates,(LatLng) so it seems like Google has made it this way, but I am currently making a custom marker and I want this position to be in the center, not directly above the coordinates. It's probably related to the render object key, but I want to edit it myself. On which page can I edit it?
Does anybody knows this issue??
(If that coordinate is a point. Make sure the dot is in the middle of the marker, not the bottom of the marker.)
I think this is the similar issue
How to center the camera so that marker is at the bottom of screen? (Google map api V2 Android)
In my Application Project i have set up a Xamarin Forms Map which centers on the users position. Now i wanted to let an icon show up when the user dragged the map somewhere to recenter on the position of the user. Unfortunately xamarin forms maps only has ja MapClicked event so eve3n when the map was dragged i have to click another time on the map so that the event is triggered. I tried using geastrue recognizers as well but somehow they neither work on the map directly nor when i impliment them on the grid over the map.
After some time i thought about checking wether the map position equals the users position and i found this tutorial https://xamarinhowto.com/xamarin-forms-maps-getting-location-radius-of-users-input/ unfortunately this did not work for me either since the code could not handel .Log() for strings.
Do you have a solution for my problem? The recenter icon should just appear as it is in Ios Maps when i dragged the map from my position.
Fairly new to Mapbox and getting there (slowly).
I have a map initially loaded at zoom level 1 for use in a web browser. When a user clicks on a marker, it'll center and zoom to level 10.
When that marker loses focus, I'd like to zoom back out to level 1.
This page discussing web applications does it (link below), but there doesn't seem to be (that I can find - sorry!) any documentation on how to achieve this.
https://docs.mapbox.com/help/getting-started/web-apps/
Any and all help appreciated!
For the first event, to zoom in when clicking a marker, you could adapt this example to zoom in addition to panning when calling flyTo
https://docs.mapbox.com/mapbox-gl-js/example/center-on-feature/
For the second part, you'd need to add a listener for another event depending on what you have in mind by "losing focus".
https://docs.mapbox.com/mapbox-gl-js/api/map/#map-events
I'm trying to migrate my app from Bing maps to Azure maps.
I'm adding a few custom pushpins on my map using the SymbolLayer.
When I try to zoom in or out though, my pushpins are getting displaced while my map stays static. What might be the issue?
I suspect the issue is that your anchor point of your icon does not align with the point on the icon image you want. You can adjust this in a couple of ways.
Use the icon options anchor setting. Good for most standard icon images.
Use the icon options offset setting. Good for fine tuning.
For example, if the point on your image that you want to "anchor" to the coordinates on the map is the bottom left corner of the image, you could do the following:
var layer = new atlas.layer.SymbolLayer(datasource, null, {
iconOptions: {
anchor: 'bottom-left'
}
});
Here is a sample to experiment with: https://azuremapscodesamples.azurewebsites.net/?sample=Symbol%20Layer%20Options
Here are the docs on the icon options for a symbol layer: https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.iconoptions?view=azure-maps-typescript-latest
Back in Bing Maps v7, if you dragged the route to the edge of your map, it would move the map in that direction. This saves the user from having to drop that route marker, move the map themselves, and then pick back up the marker to continue altering the route to meet their needs. For example, if you go to https://www.bingmapsportal.com/isdk/ajaxv7#DirectionsModule2, you will be able to try out this functionality. However, if you go to http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#directionsGetRequestOptions+JS, you will not see the map move as you drag the route to the edge of the map.
I have looked at the api for directionsRenderOptions (https://msdn.microsoft.com/library/mt750365.aspx) and directionsRequestOptions (https://msdn.microsoft.com/library/mt750373.aspx), but I don't see anything that seems related to being able to move the map as you drag a route. Any help would be much appreciated.
I don't believe this is a scenario that will be supported in V8. Not sure if this is something that can be easily added as all the rendering happens on an HTML5 canvas in V8 and is re-rendered when it moves. Will add a feature request for this for the team to look into.