Is there a way to run function AFTER camera movements end? (MapBox) - flutter

How can I run function after camera's movement ends e.g send API request.
I am using MapBox and map controllers
Thanks!

I think what you're looking for is moveend event.
// Set an event listener that fires
// just after the map completes a transition.
map.on('moveend', function() {
console.log('A moveend event occurred.');
});

Related

How to track the polygon change event?

I need to get the new coordinates of the polygon if the finish button was pressed. I applied pm:update, but this event is not triggered when rotating or moving the polygon. I also tried to use pm:action click, but this event does not give me the opportunity to get the coordinates of the polygon that I was changing.
Listen on the pm:edit event, it is fired directly after a change is happend.
polygon.on('pm:edit', (e)=>{
console.log(e);
});

Leaflet catch fitBounds event, but not moveend

Is it possible to catch only fitBounds event, but not moveend event?
There is no Leaflet built-in event dedicated to the fitBounds method. But since this method is called imperatively, you can easily execute whatever code you want alongside it.
map.fitBounds(myBounds);
// some code related to fitBounds
// e.g. you can trigger your own event:
map.fire("fitbounds-custom-event");
What may be implied by your question, is to detect the end of the potential fitBounds animation, as opposed to the end of user-initiated navigation (user pan, zoom...). Unfortunately there is currently nothing built in Leaflet either for this feature, although it has been discussed for a while (see Leaflet/Leaflet #2934).
One difficulty is that you can start a programmatic fitBounds with animation, and even though that animation is quite fast, user can navigate in the middle, ending the movement prematurely and in a different position. In that case, is it still considered the end of the fitBounds animation, or end of the user navigation?
If we ignore this difficulty, then a possible solution could be to attach a one time event listener when calling fitBounds:
map.once("moveend zoomend", myCallback);
map.fitBounds(myBounds);

Stop Mapbox GL JS Zoom Event

I have a zoom listener in my mapbox gl (1.10) application
this.map.on('zoom' e => {
if (suchAndSuch()) {
stopTheZoomFromHappening(e);
}
})
I have tried e.originalEvent.preventDefault(), and e.originalEvent.stopPropagation(). I have also tried listening to the zoomstart event. The zoom is not cancelled.
I know there is disableScrollZoom, and other disable<type>Zoom, but it seems cumbersome to disable, enable in this way.
Is there a way to stop a single zoom event from having an effect on the map?

Is it possible to make a Bing Maps TileLayer clickable?

There are Data Layer Events with which you can add e.g. click events to the Layer Class. How can I add event handlers to the TileLayer Class?
In the WMS Tile Layer Example I wish I could add the following lines of code:
Microsoft.Maps.Events.addHandler(NOAAWeatherRadar, 'click', function() {
// add infobox
});
Is this realizable or do you know of a workaround?
Tile layers do not have mouse events in any map control. Tile layers cover the complete surface of the map. If you want a mouse event simply add an event to the map itself. If you want to be able to detect a mouse event on a shape drawn in the tile layer, then you will need to do some server side processing to test for intersection against the raw data.

disabling 'grab' panning for bing maps control

How do I disable just the grab aspect of panning for bing maps AJAX control 7.0?
I have tried this -
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), { credentials: "bing maps credentials", mapTypeId: Microsoft.Maps.MapTypeId.road, disablePanning: true});
But setting the disablePanning property in the map options not only disables grab panning but also zoom panning. Zoom becomes not completely disabled but instead will only zoom in and out on the center of the map. No doubt you will have come accross zoom panning where you can use the mouse scroll wheel to zoom in on the map under the cursor and therefore can pan around by zooming in and out and moving the cursor. I would like to have zoom panning enabled but grab panning (where the user depresses the mouse and drags it around) to be disabled.
I am aiming for functionality very similar to when using the my places editor on the main bing maps site. When using the polyline tool to draw on the map grab panning is disabled and zoom panning is enabled just as I would like. I am actually intending on creating a custom drawing tool similar to the polyline tool in the my places editor.
I have been studying the api but have not discovered how to do it yet. I have also tried to discover how it is done on the main bing maps site but as the javascript code is all minified I am finding it very difficult. I have managed to gleen that the polyline tool hijacks the mouse, but that is about all.
Surely there must be a simple way of doing this. How is it done?
I don't think there is a map option you can set to achieve the behavior you want(enable zoom panning/disable grab panning). However, there is an easy way to hack it. The panning is initiated by the user clicking down on the map and moving the mouse. So if you can supply your own mousedown event handler for the map, and in its implementation prevent the default behavior of the mousedown, you should be good to go. Turns out the handled property on MouseEventArgs does just this:
Microsoft.Maps.Events.addHandler(yourMapObj, 'mousedown', function (mouseEvent) {
mouseEvent.handled = true; //A boolean indicating whether the event is handled. If this property is set to true, the default map control behavior for the event is cancelled.
});
With this, mousedown events on the map are processed by you and ignored by the map. So when the user tries to pan the map using the mouse, nothing happens. They can still click and zoom around as usual. Keep in mind if you have other elements on the map such as pushpins and shapes, this will prevent the mousedown event from reaching them. So any mousedown event handlers you registered on them will not get called. You can handle this either by unregistering the above handler when you want the other mousedown events to be called(preferable), or interogate the target property on your MouseEventArgs to see what fired the mousedown(messy).