How can I get the current distance from earth inside the Map? - flutter

I would like to maintain the current zoom level when a location change is triggered.
Currently, I display the location as follows:
_mapController.camera
.lookAtPointWithDistance(coordinates, distanceInMetersFromPosition);
The problem is that the user can zoom in or out and then move and as soon as the position changes, the piece of code is triggered again. So my question is:
Is there a callback for changing the distanceInMetersFromPosition or can I somehow get the current distanceInMetersFromPosition or zoom? I didn't find any documentation about this so far.
I’m using the "HERE SDK for Flutter (explore Edition) - Version 4.3.2.0".

The camera contains information about the current state. You can call the following:
double distanceInMetersFromPosition =
_mapController.camera.state.distanceToTargetInMeters;
Alternatively, you can use lookAtPoint(coordinates) when you just want to update the location without changing the zoom. If you are interested in callbacks, you can attach an observer to the camera with addObserver(MapCameraObserver observer). This will notify you whenever the user has zoomed or panned the map.

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

Google Map SDK Swift, Zooming in and out like Uber's Map

I am trying to implement the Google Map SDK, and so far I have implemented a marker. I made the marker in a way that it follows as it is located in the center when I move the camera position.
The problem is that I can't zoom in and out while the marker's location is not changing. I would like to make the zooming experience like Uber in which the location does not change.. Thank you for your help.
You can use this line allowScrollGesturesDuringRotateOrZoom to your GMSMapview. It controls whether rotate and zoom gestures can be performed off-center and scrolled around. The default value of this is YES.
mapView.settings.allowScrollGesturesDuringRotateOrZoom = false // NO for obj-c and false for swift
So by setting it by NO/false, you can now perform zooming while the marker location is not moving. For more information, check this thread.

Osmdroid, Custom Overlay Drawing

For an Android App I have created a custom overlay here, to display various items of game data on the map.
In general the overlay works fine and smoothly!
However there is one geometrical constellation which is not working as expected: Some objects within the overlay are not bound to geocoordinates, but to current user location. Now it happens, that Osmdroid is selectively redrawing the screen. When the screen is not focussed to user location, the user location bound stuff is not updated correctly: New stuff gets only drawn in some selective rectangle, old stuff isn't deleted outside that rectangle.
So far I failed to find a mechanism to communicate the required redraw of an overlay to the basic Osmdroid system? I.e. to invalidate the surroundings of the current user location? Any hint, clue or pointer?
By studying the sample code I realized they really consider it the overlay responsibility to issue appropriate invalidate calls to the map component to ensure their own optical integrity.
I am still struggling with the coordinates to do the right invalidate(left, top, right, buttom) calls cause my updates actually happen on location changes and it is unclear to me if the screen pixel of the map to be invalidated need to get measured relative to the old location or the new one. This is actually a timing question.
However taking the CPU byte and issuing postInvalidate() just looks as intended and it is unclear how much performance is really lost.

how to get current location as i slide the MapView?

I am using CLLocationManager to retrieve current location in my app and display using MapView, i want to slide the map so that the current location should also change to the new location where the map slides and it should annotate to the new location, how to do it? Please give your suggestions with sample code.
You probably don't mean "the current" since that means where the phone actually is, unless you want to transport the phone to another place when using this app which would be quite a feat. So, how about drawing a layer over the top of your map that keeps a pin drawn at the centre so it looks as if the pin is moving over the map, but really the map is moving under the pin.

user location Blue marble drop

Does anyone know what triggers the blue marble animation. I know that it happens when the location gets updated but how do i trigger that event with whatever is in that property. I have an app that i would like to show the user's location when the map appears, but then clear the map of all annotations (including the user location)when the map disappears. This works fine. The problem comes in that when i try to go back into the map after removing the user location, the blue marble does not pop back in. Does anyone know how to set this animation going again?
thanks in advance.
If you set your MKMapView to show the user's location by setting its property showsUserLocation to YES, then the map will automatically show the user's location unless his/her coordinates are outside the map. You can check this by inspecting the userLocationVisible property.
Now, if you remove the user's location (the property userLocation which is an annotation), then the map can not show the user' location even if you have showsUserLocation set to yes.
Simply restore the userLocation again by updating it using the CoreLocation framework and it will appear automatically on the map again.
EDIT: To trigger the animation, update the user's location, setup again the region to be shown (may be the center and/or span have changed) and then call
[map setRegion:newRegion animated:YES];
If the region didn't change simply reuse it.