Esri ArcGIS 地图未显示正确的固定点 WPF
本文关键字:WPF ArcGIS 地图 显示 Esri | 更新日期: 2023-09-27 18:35:10
我有使用 ESRI 地图控件的 WPF 应用程序。这是我的 XAML 和 C# 代码。问题是它在地图上向我显示针点,但它显示我在一个错误的地方,即非洲的某个地方。我认为它将纬度和对数作为 0,0,即中心。任何人请帮助我解决问题,使地图指向正确的位置。
<Border CornerRadius="10" BorderThickness="10" Background="LightBlue">
<!--ESRI-->
<esri:Map Name="DashboardMap" Width="550" Height="300" BorderThickness="3" WrapAround="True" IsLogoVisible="False" Loaded="DashboardMap_Loaded" Margin="5,5,0,0">
</esri:Map>
</Border>
这是我的CS代码。
private void DashboardMap_Loaded(object sender, RoutedEventArgs e)
{
Layer Arlayer = new ArcGISTiledMapServiceLayer
{
ID = "StreetLayer",
Url = "http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer"
};
DashboardMap.Layers.Add(Arlayer);
}
GraphicsLayer layer;
MapPoint point = new MapPoint(37.428433999999996, -122.0723816);
point.SpatialReference = new SpatialReference(102100);
//point.SpatialReference = new SpatialReference(4326);
//point.SpatialReference = DashboardMap.SpatialReference;
layer = new GraphicsLayer();
layer.Visible = true;
ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol symbol = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
symbol.Color = new System.Windows.Media.SolidColorBrush(Colors.Red);
symbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle;
symbol.Size = 15;
Graphic graphic = new Graphic();
graphic.Symbol = symbol;
graphic.Geometry = point;
graphic.SetZIndex(1);
layer.Graphics.Add(graphic);
DashboardMap.Layers.Add(layer);
}
}
MapPoint 按该顺序获取参数 x 和 y,因此首先是经度,然后是纬度。
你应该写:
var point = new MapPoint(-122.072382, 37.428434, new SpatialReference(4326));