我正在通过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;
}
}
我做错了什么?我假设它与spatialReference有关,但地图空间参考为空。救命啊!
答案 0 :(得分:1)
发现了这个问题。虽然通过示例说明GeographicToWebMercator是可选的,但显然不是。当我更换线
wellsLayer.Graphics[0].Geometry = location;
带
wellsLayer.Graphics[0].Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(location);
地图标记移动到基于我的地图点的位置,因为虽然纬度和经度对于给定的Spacial参考系统可能是正确的,但是bing map系统必须将这些值转换为它知道如何在目前的预测。
希望这有助于其他人!