I'm displaying a mapview and want to get the latitude and longitude of the center, how can I do this?
Hi Julian,Try this workflow:1. Get the map view's visibleArea,2. Retrieve the extent envelope of that polygon,3. Get the center point of envelope,4. Access x & yCheers,Mike
So I tried that but I am getting really weird numbers: I have the map set for
latitude = -34.0, longitude = 151.0
but when I print the log for lat and lon using
val lat = binding.map.visibleArea?.extent?.center?.x!!val lon = binding.map.visibleArea?.extent?.center?.y!!
i get lat: 1.680924310978431E7 , lon:-4028802.026134409
Looks like you're getting back coordinates in meters (likely from a Web Mercator spatial reference set on the map).Two options:
val viewpoint = binding.mapView.getCurrentViewpoint(ViewpointType.CenterAndScale) val latLongPoint = viewpoint?.targetGeometry?.extent?.center
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.