我正在通过 Silverlight API 教我自己的 arcGIS 地图工作,我试图在 XY 示例中做一个简单的放置标记符号,但如果我不能让它工作,那就该死了!我使用以下示例页面作为参考,但是当我去调试这个东西时,我的标记总是以地图的死点结束,不管 MapPoint 的 X 和 Y 值是什么:
我的 xaml 如下所示:
<UserControl x:Class="CustomGeometry.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="mapWells" Loaded="mapWells_Loaded">
<esri:ArcGISTiledMapServiceLayer x:Name="BaseLayer" ID="Base Map" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
</esri:Map>
</Grid>
</UserControl>
我的后端代码如下所示:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
/// <summary>
/// creating Wells Layer
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void mapWells_Loaded(object sender, RoutedEventArgs e)
{
GraphicsLayer wellsLayer = mapWells.Layers["WellsLayer"] as GraphicsLayer;
if (wellsLayer == null)
{
wellsLayer = new GraphicsLayer()
{
ID = "wellsLayer"
};
mapWells.Layers.Add(wellsLayer);
Graphic marker = new Graphic();
marker.Symbol = new SimpleMarkerSymbol();
wellsLayer.Graphics.Add(marker);
}
// map point not being set correctly.
MapPoint location = new MapPoint(-122.466903686523, 48.7440490722656, mapWells.SpatialReference);
wellsLayer.Graphics[0].Geometry = location;
}
}
我究竟做错了什么?我假设它与空间参考有关,但地图空间参考为空。帮助!