如何自定义Bing地图Silverlight控件上的图钉样式?我已阅读此处显示的文档(http://www.microsoft.com/maps/isdk/silverlightbeta/#MapControlInteractiveSdk.Tutorials.TutorialCustomPushpin)。但是,我正在编程添加可变数量的图钉。理想情况下,我希望能够设定每个pushin的风格,但我不知道如何。Silverlight - Bing地图 - 自定义图钉样式
4
A
回答
6
你有2种方式去:
(1)创建任何的UIElement通入PushPinLayer.AddChild。该方法的AddChild将接受和任何的UIElement,如在这种情况下的图像:
MapLayer m_PushpinLayer = new MapLayer();
Your_Map.Children.Add(m_PushpinLayer);
Image image = new Image();
image.Source = ResourceFile.GetBitmap("Images/Me.png", From.This);
image.Width = 40;
image.Height = 40;
m_PushpinLayer.AddChild(image,
new Microsoft.Maps.MapControl.Location(42.658, -71.137),
PositionOrigin.Center);
(2)创建原生对象图钉通入PushpinLayer.AddChild,但首先设置它的模板属性。请注意,图钉的是ContentControls,并且具有可以在XAML中定义的资源设置模板属性:
MapLayer m_PushpinLayer = new MapLayer();
Your_Map.Children.Add(m_PushpinLayer);
Pushpin pushpin = new Pushpin();
pushpin.Template = Application.Current.Resources["PushPinTemplate"]
as (ControlTemplate);
m_PushpinLayer.AddChild(pushpin,
new Microsoft.Maps.MapControl.Location(42.658, -71.137),
PositionOrigin.Center);
<ResourceDictionary
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="PushPinTemplate">
<Grid>
<Ellipse Fill="Green" Width="15" Height="15" />
</Grid>
</ControlTemplate>
</ResourceDictionary>
1
我将通过创建一个图层,然后加入我的图钉到该层做到这一点。
// during initial load
MapLayer lay = new MapLayer();
MapControl.Children.Add(lay);
// for each pushpin you want to add
Image image = new Image();
// this assumes you have an "Images" folder on the root of your host web application
image.Source = new BitmapImage(new Uri(App.Current.Host.Source, "../Images/PushPin.png"));
var lat = 40.4d;
var long = -81.8d;
Location location = new Location(lat, long, 0d);
//Define the image display properties
image.Opacity = 1.0;
image.Stretch = Stretch.None;
// Center the image around the location specified
PositionOrigin position = PositionOrigin.Center;
//Add the image to the defined map layer
lay.AddChild(image, location, position);
1
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim pushpin As Microsoft.Maps.MapControl.Pushpin = New Microsoft.Maps.MapControl.Pushpin
pushpin.Template = Application.Current.Resources("PushPinTemplate")
End Sub
给我任何错误......
相关问题
- 1. Bing地图Silverlight控件自定义图钉
- 2. Silverlight - Bing地图控件 - 图钉集群
- 3. bing地图图钉
- 4. 在Bing地图中使用图钉附加自定义ID
- 5. 如何在Bing地图上创建自定义图钉v7
- 6. HOWTO设置Bing地图自定义图钉锚右下角
- 7. 带自定义HTML信息框的多个Bing地图图钉
- 8. 如何在自定义图钉中嵌入bing地图
- 9. 嵌入bing地图 - 图钉
- 10. 图钉不能定位在bing地图
- 11. 使用Storyboard(Silverlight)在Bing地图内部制作图钉动画
- 12. Silverlight bing地图中的可拖动AND可点击图钉
- 13. 从Bing获取带图钉的地图[silverlight]
- 14. Bing地图Silverlight控件图钉结垢问题
- 15. Silverlight - 通过C#将图钉添加到Bing地图
- 16. 更新Silverlight的Bing地图图钉的位置控制
- 17. Silverlight - Bing点击导航图钉
- 18. 用Bing地图突出显示图钉
- 19. Bing地图在REST中的图钉
- 20. 的AddHandler用于Bing地图图钉
- 21. Bing地图图钉和Zoomin /缩小
- 22. bing地图图钉和鼠标点击
- 23. Bing地图图钉和信息框
- 24. 在Bing地图中添加图钉
- 25. Bing地图在使用自定义图钉时需要很多性能
- 26. 兵地图API静态地图自定义图钉图像
- 27. 自定义图钉wp7
- 28. 绑定在ObservableCollection图钉Bing地图控制WP7
- 29. Angular 2/4 Bing Map图钉自定义模板函数调用
- 30. bing地图中的自定义颜色?
user70192,这个回答你的问题?如果是这样,你能将它标记为已回答吗? – 2010-04-15 05:15:22