L.latLngBounds swapping longitude of Northeast and Southwest p - leaflet

i am trying to adjust map in a certain way.
logs of general bound:
bottomRight: (2) [11.525595058977732, 140.82915421731286]
topLeft: (2) [78.66511070565068, -30.206002032687138]
But the LatLng function is changing swapping longitudes:
_northEast: LatLng {lat: 78.66511070565068, lng: 140.82915421731286}
_southWest: LatLng {lat: 11.525595058977732, lng: -30.206002032687138}
What should i do to prevent this behavior, is there any workaround available?

Related

How can I get Camera Altitude in MapBox GL JS?

I know that using
const camera = map.getFreeCameraOptions();
const cameraPosition = camera._position.toLngLat();
I can get at cameraPosition the longitude and latitude from the camera, but what about the elevation/altitude?
What exactly is then, following the previous code:
const elevation = camera._elevation;
And why is always with the value undefined?
How can I get the correct altitude value?
Thanks in advance,
Joan.

Leaflet/Leaflet Routing Machine: Is there a method to determine if a Lat and Lang is on the street?

Using leaflet-topography I can get the elevation and slope data for a given point using Lat and Lang.
I got that data:
latlng: LatLng {lat: 40.74224422475555, lng: -73.76170149999999}
topography:
aspect: 279.4623222079068
elevation: 29.600000000000364
resolution: 57.847966427070006
slope: 1.2047623336529816
[[Prototype]]: Object
But is there a function out there to say:
With a given latitude and longitude I'll tell you if its on the street?
Thanks in advance!

Moon CSR example file

I'm trying to make an moon CRS JS file, but my géo-mathematics are not very good, in fact, i don't understand ! But i've a to do a scientifics experience, can you help me ? Peraphs it can be done with just configuration.
Let me explain, i need to set magnetic north pole on moon map.
I use moon map from: https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/{z}/{x}/{y}.png
I need to change pole north, because when i set a marker to [0,0], the marker appear not where i want. In other manner, i need to move north pole where i want. On earth, and moon if i want.
After that, i ll set pointer from public data and whatch what it done. On moon, on earth, on personal photo.
thanks i'll try to find it
const map = L.map('map', {
// crs: L.CRS.EPSGMoonMercator, // MoonMercator
// crs: L.CRS.EPSGMoonSphericalMercator, // MoonMercator
// crs: L.CRS.EPSG3395, // Mercator
crs: L.CRS.EPSG3857, // SphericalMercator
center: [-70,0],
zoom: 4,
// minZoom: 3,
// maxZoom: 8,
});

Why do my functions under _onCameraMove run so poorly?

If I pass latlnglastPosition to my widget, it's fine. I can see latitude and longitude and the value changes with zero lag as my camera position changes. However, using anything more than that causes crazy lag. It's practically unusable. Does anybody know what's causing this or if there's a better way of doing this? I'm trying to display latitude, longitude, altitude, distance from center versus current position in meters and miles. Here's the code:
void _onCameraMove(CameraPosition cameraPosition) async {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
lat = position.latitude;
lng = position.longitude;
alt = position.altitude;
_distancebetween = await Geolocator().distanceBetween(
_lastMapPosition.latitude, _lastMapPosition.longitude, lat, lng);
distancebetweenFinal = _distancebetween.toStringAsFixed(2);
distancebetweenFinalMiles = _distancebetween * (0.000621371);
_lastMapPosition = cameraPosition.target;
var latlnglastPosition = _lastMapPosition;
_currentZoom = cameraPosition.zoom;
setState(() {
latlnglastPosition;
distancebetweenFinal;
distancebetweenFinalMiles;
_distancebetween;
_lastMapPosition;
});
}
This is using Flutter Google Maps.
Edit: I removed the conversion from meters to miles. It didn't help. I don't think the altitude is having any impact. It's just going from current camera view position to my current position that's delaying everything. Is there perhaps a way to increase the frequency i receive location info? maybe that's hanging things up.... ?
Edit: or maybe I can use get last known position when a new location is not available? Not sure if that's the best way to handle this
Edit: I set lat = 34.0; lng = 34.0; and it's super fast now. However, it doesn't solve my problem. I need lat and lng to reflect my current position, and it seems i'm either restricted in pulling my current position or it's too costly to pull it as frequently as I need to. I don't know the best way to handle this... Any ideas are appreciated.
I got it (I think):
I replaced
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
with:
Position position = await Geolocator().getLastKnownPosition();
I think position.latitude and position.longitude were too costly before. So, I'm getting the last known position. If anyone knows a better way, please let me know.

Not understanding how to use the return value of leaflet getCenter()

I'm trying to put a marker at the center point of these coordinates. After calculating the bounds, I use getCenter() to give me the coordinates. But it returns "LatLng(-93.20448, 38.902475)" in longitude latitude direction, so using them in the marker doesn't work. It needs lat lon. I realize I'm not understanding something but what is it that I don't understand.
var bounds = L.latLngBounds([[-94.778092, 39.967458], [-91.630869, 39.967458], [-91.630869, 37.8374921], [-94.778092, 37.8374921], [-94.778092, 39.967458]]);
var middle = bounds.getCenter(); alert(middle); // LatLng(-93.20448, 38.902475)
var mk5 = new L.marker(new L.latLng( 38.902475, -93.20448 );