2015-03-31 71 views
0

我有一個用Uri類型爲我的圖像的想象源,我想把它作爲我的MapIcon的源代碼,因爲我需要調整圖像大小。如何將圖像類的圖像源設置爲MapIcon Windows Phone 8.1

MapIcon mapIcon = new MapIcon(); 

     mapIcon.NormalizedAnchorPoint = new Point(0.25, 0.9); 
     //mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/icons/map.png")); 

     mapIcon.Location = geoposition.Coordinate.Point; 
     mapIcon.Title = "Você está aqui"; 

     MapControl1.MapElements.Add(mapIcon); 

Image im = new Image(); 
     im.Source = new BitmapImage(new Uri("ms-appx:///Assets/icons/view.png")); 
     im.Width = 65; 
     im.Height = 65; 

我怎樣才能把我的圖片裏面MapIcon?謝謝!

回答

-1
Geopoint myPoint;  
BasicGeoposition location = new BasicGeoposition(); 
var locator = new Geolocator(); 
       locator.DesiredAccuracyInMeters = 50; 
       var position = await locator.GetGeopositionAsync(); 
       myPoint = position.Coordinate.Point; 

MapIcon MapIcon = new MapIcon(); 
MapIcon.Location = new Geopoint(new BasicGeoposition() 
     { 
      Latitude = myPoint.Position.Latitude, 
      Longitude = myPoint.Position.Longitude 
     }); 
     MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0); 
     location.Latitude = myPoint.Position.Latitude; 
     location.Longitude = myPoint.Position.Longitude; 


     Geopoint pointToReverseGeocode = new Geopoint(location); 
     MapLocationFinderResult result = 
      await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode); 
     //MapIcon.Title = result.Locations[0].Address.Street; 
     MapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/icons/view.png")); 
     YourMap.MapElements.Add(MapIcon); 
1

從來沒有在所有我一直在閱讀關於這個問題的頁提及....使用的資產文件夾中的本地文件作爲您的地圖圖標,你必須將它添加到項目...在解決方案資源管理器展開資源,rt單擊資產,單擊添加,選擇現有項目,導航到您的項目的資產文件夾,然後選擇您的圖像文件。

相關問題