[英]How to create and append PushPins to map using ArcGis API?
大家好,我想使用ArcGis API在地图内创建PushPin。经过长时间的研究,唯一可行的选择似乎是在地图层之上添加图形层并在其上绘制符号。
但是在我尝试了以下代码并在WP7仿真器上运行之后。 当我单击地图时,似乎没有生成PushPin。 任何帮助是极大的赞赏。 真的提前很多。
*注意代码示例中的map1指的是ArcGis Map对象
代码示例:
private void map1_MapGesture(object sender, Map.MapGestureEventArgs e)
{
SimpleFillSymbol fillSymbol = new SimpleFillSymbol()
{
BorderBrush = new SolidColorBrush(Color.FromArgb(0, 255, 0, 0)),
BorderThickness = 2,
Fill = new SolidColorBrush(Color.FromArgb(255, 12, 12, 255))
};
GraphicsLayer layer = map1.Layers["PushpinLayer"] as GraphicsLayer;
Graphic g = new Graphic();
g.Symbol = fillSymbol;
g.Geometry = e.MapPoint;
layer.Graphics.Add(g);
}
我使用了下一个代码在地图上绘制图钉:
<Maps:Map>
<Maps:MapItemsControl ItemsSource={Binding Pushpins} ItemTemplate={StaticResource CustomTemplate} />
</Maps:Map>
当Pushpins
是你有里面的对象集合的公共属性GeoCoordinate Location
放置图钉上的具体位置。
您可以在手势事件上添加新项目:
Pushpins.Add(new Pushpin(...));
另外,请考虑将ObservableCollection
用作图钉收集类型
谢谢所有看过我的帖子的人:)并且特别是如果回答= P
无论如何,我发现问题出在我的xaml中,我将图形层放在地图层之前,因此无法渲染图形。
无论如何,这应该是订购元素= P的正确方法
非常感谢您的帮助:)
<esri:Map Background="White" HorizontalAlignment="Left" Name="map1" VerticalAlignment="Top" WrapAround="True" Height="607" Width="468" MapGesture="map1_MapGesture">
<esri:Map.Layers>
<esri:LayerCollection>
<esri:ArcGISTiledMapServiceLayer Url="http://www.onemap.sg/ArcGIS/rest/services/BASEMAP/MapServer" />
<esri:GraphicsLayer Visible="True" ID="PushpinLayer" />
</esri:LayerCollection>
</esri:Map.Layers>
</esri:Map>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.