0

我正在通过 Silverlight API 教我自己的 arcGIS 地图工作,我试图在 XY 示例中做一个简单的放置标记符号,但如果我不能让它工作,那就该死了!我使用以下示例页面作为参考,但是当我去调试这个东西时,我的标记总是以地图的死点结束,不管 MapPoint 的 X 和 Y 值是什么:

http://blogs.esri.com/dev/blogs/silverlightwpf/archive/2010/12/14/adding-gps-location-to-the-map-in-the-arcgis-api-for-windows-phone。 aspx

我的 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;

        }
    }

我究竟做错了什么?我假设它与空间参考有关,但地图空间参考为空。帮助!

4

1 回答 1

1

发现问题。虽然演练示例表明 GeographicToWebMercator 是可选的,但显然不是。当我更换线路时

wellsLayer.Graphics[0].Geometry = location;

wellsLayer.Graphics[0].Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(location);

地图标记移动到基于我的地图点的位置,因为虽然纬度和经度可能对给定的空间参考系统是正确的,但必应地图系统必须将这些值转换为它知道如何在当前投影上显示的值。

希望这对其他人有帮助!

于 2011-05-09T15:50:15.247 回答