简体   繁体   English

显示比例线-ArcGIS Runtime SDK-Xamarin.Forms

[英]Display scale line - ArcGIS Runtime SDK - Xamarin.Forms

I am using the 1st release of the ArcGIS Runtime SDK for .Net - Xamarin.Forms (nuget package here ). 我使用的是.Net的ArcGIS Runtime SDK的第1版-Xamarin.Forms( 此处为Nuget包)。

One of my requirements is to display a basic scale line on the map. 我的要求之一是在地图上显示基本比例尺线。 I haven't found any build-in feature for the moment. 目前我还没有发现任何内置功能。 It seems to be tricky because each device has different size, different resolution... Any idea on how to implement this ? 这似乎很棘手,因为每个设备具有不同的大小,不同的分辨率...关于如何实现此功能的任何想法?

OK after few hours, I found that the MapView component has a property UnitsPerPixel that do exactly what I needed: 几个小时后确定,我发现MapView组件具有一个属性UnitsPerPixel ,可以完全满足我的需要:

I've added a small grid (to represent the scale) with a fix width: 我添加了一个固定宽度的小网格(代表比例):

<Grid  HeightRequest="10" WidthRequest="114" x:Name="Legend">
...
</Grid>

Then when the view point changes, I compute the distance representing by this grid: 然后,当视点更改时,我将计算此网格表示的距离:

MapView.ViewpointChanged += (sender, args) =>
{
    ScaleVal.Text = $"{Math.Round(Legend.Width * MapView.UnitsPerPixel, 0)}m";
};

ArcGIS .Net SDK-Xamarin.Forms-比例线

Complete solution here . 完整的解决方案在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM