Xamarin Forms Maps Scroll Event - forms

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.

Related

Mapbox Reset Zoom when Marker deselected

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

How to let the user to build a polygon on the open street map?

UPD: Done. Look at this beautiful polygon.
UPD: In Flutter / openstreetmap, I want to let users draw a polygon by tapping a map and/or clicking a button. The polygon should be not filled. I need a very simple example just to get an idea of how it works.
The final task is:
I am making a flutter application that should give the user the ability to get information about markers located within a certain area on the map. I use osm. By pressing the button, the user initiates the construction of an arbitrary polygon, each corner of which is formed at the place of the next pressing of the button. When the construction of the polygon is completed, the objects inside the polygon are shown, the rest are hidden or not built. After that, the cycle ends by clearing the map.
I haven't found any solution for osm. I would appreciate any help. I don't have any code yet)
You can use the flutter_map library, I'm sure you can understand the documentation and how to set it up.
Then use PolygonLayerOptions(polygons: [Polygon(points: polygonList)]) as a layer on top of the OSM layer. Then set up the list polygonList and use the FlutterMap()'s onTap callback to get the position at which the user tapped and add the LatLng to the polygonList list. There are multiple other configuration options within the Polygon() constructor, and those can be found through IntelliSense or similar. To have no fill, just set the color to transparent.
I use this method (or a very similar one) for my app which lets users download areas of map. The user taps the top left and bottom right of a rectangular area they want to download, by code calculates the top right and bottom left, and a polygon is drawn to show the user exactly where they tapped. Make sure to use setState() or similar.

Two cursors on maps at same time in Mapbox GL-JS

I am developing a weather radar viewer using Mapbox. In a certain mode, there are 2 Mapbox maps on the screen at the same time showing different modes of the radar. The maps are locked to each other. When one map moves, rotates, or pans - the other one does as well. I did this by simply passing the properties of one map to the other. In the below screenshot, you will see how they are showing identical locations.
What I want to do is - when the user is hovering the mouse over "map1", I would like an identical (ghost or false) cursor on "map2". Here is what I am looking to do:
(edit: What you are looking at is an actual screenshot. Each map is enclosed in a DIV with 50% width of the screen, if this helps to explain)
I don't know if this is even possible in Mapbox. Hopefully someone can give some guidance as I can't find any other questions related to this and I really have no code to show without knowing where to start.
If you attempt to do this inside Mapbox-GL-JS (for instance, by constantly updating the location of a GeoJSON feature layer), I think the performance will be pretty poor.
But since the two views are exactly locked (and presumably the exact same dimensions), you can just do this at an HTML/CSS level. Detect mouse movement on the first map, and update the location of an absolutely-positioned element hovering over the second map to match.
Another approach would be using a canvas element overlaid over the second map, similarly updated.

How to detect when user does not click on a layer? Leaflet

I am using leafletjs in a project. On the map I have several polygons and markers. There is a click event on all of them to display some information when one of them is clicked. I would like to take the information away if the user clicks on a 'blank' part of the map (not on any polygons or markers). I know the map has the 'click' event but so far I am struggling to find a way to detect if the user clicked on a layer. Any advice?
you can use preclick event to clear all the data
https://leafletjs.com/reference-1.2.0.html#map-preclick

Mapbox: Center map after popup closes

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