2014-10-27 97 views
1

我正在构建一个windows phone 8.1应用程序,该应用程序读取一个文件(其中包含GPS点,每个点包含例如纬度和经度字段)。对于每一个点我都有,所以它在地图控件上显示一个小图钉图标,基于它从上面的文件进行协调。有什么方法可以在推针元素上实现点击事件并将其用于例如显示另一个窗口,用户可以更改/显示特定点/图钉信息(经度或纬度)?这是我使用读取地图上我的文件,并显示什么,以及它工作得很好:地图图钉点击事件

信息:notespublic ObservableCollection<Point> notes;

protected async override void OnNavigatedTo(NavigationEventArgs e) 
    { 
     bool exist; // used to check if JSON file exists 

     // get current position and set the map to point at it 
     Geoposition position = await App.DataModel.GetCurrentPosition(); 

     await MyMap.TrySetViewAsync(position.Coordinate.Point, 16D); 

     mySlider.Value = MyMap.ZoomLevel; // set it to 16D from previous line 

     exist = await App.DataModel.FileExistsAsync(); 

     if (exist == true) 
     { 
      // read the file and load points into a list 
      await App.DataModel.ReadFile(); 

      // put points on the map - little map icon 
      foreach (var point in App.DataModel.notes) 
      { 

       MapIcon myMapIcon = new MapIcon(); 
       myMapIcon.Location = new Geopoint(new BasicGeoposition() 
       { 
        Latitude = point.Latitude, 
        Longitude = point.Longitude, 
       }); 
       myMapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0); 
       MyMap.MapElements.Add(myMapIcon); 
      } 
     } 
    } 

回答

3

不是因为你已经实现了,没有。如果您需要任何类型的最终用户事件,则需要使用MyMap.Children.Add(myXamlControl)而不是使用MyMap.MapElements.Add(myMapIcon)将基于XAML的图钉添加到地图。 MapIcons被集成到地图“图像”中,而不是浮在顶部,并且不能对任何东西做出反应。

编辑:这是你如何设置一个XAML控制点和锚:

MyMap.SetLocation(myXamlControl, myPoint); 
MyMap.SetNormalizedAnchorPoint(myXamlControl, new Point(0.5, 0.5)); 
+0

感谢我指出了正确的方向。现在我有一个自定义的xaml控件,可以响应用户输入 – Dodi 2014-10-27 19:01:55