2010-03-10 5 views
4

Bing Maps Silverlight 컨트롤에서 압핀 스타일을 사용자 정의하려면 어떻게합니까? 여기에 표시된 설명서 (http://www.microsoft.com/maps/isdk/silverlightbeta/#MapControlInteractiveSdk.Tutorials.TutorialCustomPushpin)를 검토했습니다. 그러나 프로그래밍 방식으로 다양한 수의 압정을 추가하고 있습니다. 이상적으로, 나는 각 푸시 핀의 스타일을 설정할 수 있기를 원하지만 어떻게해야할지 모르겠다.Silverlight - Bing Maps - 압정 스타일 사용자 정의

(1)이 PushPinLayer.AddChild에 전달하는 모든 UIElement에 만들기 :

답변

6

당신은가는 2 가지 방법이있다. 하는 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에 전달하는 기본 압정 개체 만들기,하지만 먼저는 템플릿 숙박 시설의 설정.

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> 
+0

user70192,이 귀하의 질문에 대답 했습니까? 그렇다면 답변으로 표시 할 수 있습니까? –

1

내가 레이어를 만든 다음 해당 레이어에 내 푸시 핀을 추가하여이 작업을 수행 할 것입니다 : 압정의가 ContentControls, 그리고 XAML에 정의 된 자원에서 설정할 수있는 템플릿 속성이 있습니다. 나에게 오류를 제공하지

// 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 

...

관련 문제