Select to view content in your preferred language

Optimised scale for distant points

558
3
Jump to solution
05-05-2022 07:52 AM
vergerk
Occasional Contributor

Hello,

I have defined several remote points of interest on my 2D map and the scale is not appropriate.

Not wanting to put an arbitrary value in MainMapView.SetViewpointScaleAsync(value), is there a function to adapt the scale to display all the points present?

Or how is the scale calculated?


Thanks !


Sincerely

0 Kudos
2 Solutions

Accepted Solutions
KeithGanzenmuller
Frequent Contributor

If your points are in a layer it's possible to set the ViewPoint to the Layer.FullExtent envelope

myMapView.SetViewpointAsync(new Viewpoint(YourLayerEnvelope));

 Of course you have to obtain the YourLayerEnvelope

View solution in original post

0 Kudos
Nicholas-Furness
Esri Regular Contributor

If you have your point of interest geometries, you could also use GeometryEngine.combineExtents to get the minimal containing envelope. You can then pass that envelope to MapView.SetViewpointGeometryAsync() (that's a shortcut/equivalent to the method that Keith mentioned above).

View solution in original post

0 Kudos
3 Replies
KeithGanzenmuller
Frequent Contributor

If your points are in a layer it's possible to set the ViewPoint to the Layer.FullExtent envelope

myMapView.SetViewpointAsync(new Viewpoint(YourLayerEnvelope));

 Of course you have to obtain the YourLayerEnvelope

0 Kudos
Nicholas-Furness
Esri Regular Contributor

If you have your point of interest geometries, you could also use GeometryEngine.combineExtents to get the minimal containing envelope. You can then pass that envelope to MapView.SetViewpointGeometryAsync() (that's a shortcut/equivalent to the method that Keith mentioned above).

0 Kudos
vergerk
Occasional Contributor

Hello,

I had tried this approach by creating the envelope myself but nothing worked because I had not specified the spatial reference frame...

Thanks for your solutions, they are cleaner than the one I used 🙂

0 Kudos