Displaying the ratio scale of a map

2611
9
03-02-2020 09:09 AM
MartinBoulanger
New Contributor II

I'm trying to get the scale of a simple base map.

        ArcGISMap map = new ArcGISMap(SpatialReferences.getWebMercator());
        map.setBasemap(Basemap.createImagery());
        map.setMaxScale(MAX_DISPLAYABLE_SCALE);

        MapView mapView = new MapView();
        mapView.setMap(map);

The scale returned by the following code seems to be inaccurate and I cannot figure out why. 

         mapview.addMapScaleChangedListener(scale->System.out.println(scale.getSource().getMapScale()));

Using this code: GitHub - Esri/arcgis-runtime-toolkit-java: Runtime Java SE toolkit, I was able to display a scale bar which seems to be of the right length. 

Am I doing something wrong?  Did I forget something?

0 Kudos
9 Replies
JonL
by Esri Contributor
Esri Contributor

Hi Martin,

Would you be able to share some details regarding the inaccuracy you are observing in the return values of .getMapScale() ? This might help us better understand the issue and offer some more focused support.

Thanks,

Jonathan

0 Kudos
MartinBoulanger
New Contributor II

Hi Jonathan,

Thanks for the quick reply.

The first thing I did was to measure the length of some real world object using Google Map measuring tool.

Measuring a distance with Google Map

Then I measured that same object on my screen (in my application developed using ArcGIS Java SDK), using the scale to calculate the real world distance.

As you can see the result is off by more than a 123 meters.  The scale returned by ArcGÌS does not seem to be accurate.

Thanks again.

Martin

0 Kudos
GayleYoung
Esri Contributor

Hi Martin,

an you clarify how you "measured that same object on my screen". Did you try creating and measuring a Line Graphic in the GraphicOverlay, or measure a distance with the GeometryEngine?

Thanks,

Gayle.

0 Kudos
MartinBoulanger
New Contributor II

Hi Gayle,

I basically did the same thing as you would do with any map, I physically measured the distance between two points on the map with a ruler (using a popular photo editing software to be more precise).  This gave me 12.33 cm as shown on the screenshot in my previous message.  I was then able to estimate the real distance by multiplying this by the scale ratio returned by ArcGIS. 

Our users want the scale ratio displayed on the map and to be able to "jump" to specific ratio (1:10000, 1:50000, 1:100000, ...).  How can I achieve this?  Is the ratio published by ArcGIS reliable?

Thanks again for your help!

0 Kudos
JonL
by Esri Contributor
Esri Contributor

Hi Martin,

The best way to measure distances using the API is with GeometryEngine.distanceGeodetic() or GeometryEngine.lengthGeodetic(), as that will take into accound the map's spatial reference correctly.

We've double checked, and the distances returned by this method are correct.

For setting the viewpoint to a specific scale, you could use MapView.setViewpointScaleAsync(double) 

or .setViewpointCenterAsync(Point,double) .

Please let us know if this works well for you, or if you have any other questions.

Thanks,

Jon

0 Kudos
MartinBoulanger
New Contributor II

Hi Jon,

We already have implemented a tool to measure distances using GeometryEngine.distanceGeodetic() and it has been working as intended at any scale since the beginning, so no issues with that.

We also performed some tests with the ScaleBar from the Java Toolkit GitHub - Esri/arcgis-runtime-toolkit-java: Runtime Java SE toolkit and no issues with that either.

The problem is that the scale ratio returned by ArcGIS does not reflect what's displayed on the screen.  When they select 1:10000, our users are expecting that the ratio on the screen is very close to 1:10000 (like if they were looking a printed map), not 1:12387 or something like that.  How can we do this?

0 Kudos
GayleYoung
Esri Contributor

Thanks for the detail Martin. We are trying to understand the problem. Is it that

1) the user selects 1:10000 and getScale returns, for example, 1:12387. If so, can you confirm which calls you make to allow the user to select scale. Is the method as in your original post using map.setMaxScale(MAX_DISPLAYABLE_SCALE); or is it using MapView.setViewpointScaleAsync(double) suggested above, or similar?

or

2) that the scale return by getScale does not now seem accurate even when you measure using GeometryEngine.distanceGeodetic() 

0 Kudos
MartinBoulanger
New Contributor II

It's more like:

3) That the scale returned by getScale does not seem to be accurate with what's physically displayed on the screen.


For example:

-We know that the length of a bridge is 1km in the "real world"

-The bridge is displayed in ArcGIS and getMapScale() gives us a scale of 1:10000

Knowing that, the length of the bridge displayed on the computer screen should be 1km/10000=0.0001km=10cm
But it's not the case, we get something closer to 13 or 14 cm.


Of course, GeometryEngine.distanceGeodetic() will always return the right distance, but the use case here is to display the current scale ratio accurately, like on "standard paper" map.

0 Kudos
FayGlunt
New Contributor III

Hi, we are trying to do the same thing.  Is there a solution for this?

 

0 Kudos