2013-07-27 17 views
5

Zajmuję się tworzeniem aplikacji, która wykorzystuje usługę map dla Windows Phone 8.jak dodać Google Map w Windows Phone 8 Aplikacja

Śledziłem link http://themightyhedgehog.blogspot.de/2013/01/how-to-use-google-maps-in-your-own.html i stara się rozwijać aplikację zawierającą mapy Google.

Ale mam błąd w XAML na linii MapAppScope:BindingHelpers.TileSource="{Binding GoogleMap}"

i błędu dostałem to:

  1. BuildingHelpers nie jest obsługiwana w Silverlight.
  2. Załączona właściwość "TileSource" nie została znaleziona w typie "BuildingHelpers".
  3. Prefiks przestrzeni nazw "MapAppScope" nie jest zdefiniowany.

w XAML:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <Microsoft_Phone_Controls_Maps:Map 
Name="MyMap" 
Grid.Column="1" 
LogoVisibility="Collapsed" 
d:LayoutOverrides="GridBox" 
      MapAppScope:BindingHelpers.TileSource="{Binding GoogleMap}" 
      Margin="0,0,0,2"> 
      <Microsoft_Phone_Controls_Maps:Map.Mode> 
       <MSPCMCore:MercatorMode/> 
      </Microsoft_Phone_Controls_Maps:Map.Mode> 
     </Microsoft_Phone_Controls_Maps:Map> 


    </Grid> 

W .cs:

namespace Google_Map_App 
{ 
    public enum GoogleType 
    { 
     Street = 'm', 
     Hybrid = 'y', 
     Satellite = 's', 
     Physical = 't', 
     PhysicalHybrid = 'p', 
     StreetOverlay = 'h', 
     WaterOverlay = 'r' 
    } 

    public class Google : TileSource 
    { 
     public Google() 
     { 
      MapType = GoogleType.Street; 
      UriFormat = @"http://mt{0}.google.com/vt/lyrs={1}&z={2}&x={3}&y={4}"; 
     } 

     public GoogleType MapType { get; set; } 

     public override Uri GetUri(int x, int y, int zoomLevel) 
     { 
      return new Uri(
       string.Format(UriFormat, (x % 2) + (2 * (y % 2)), 
       (char)MapType, zoomLevel, x, y)); 
     } 
    } 
    public static class BindingHelpers 
    { 
     //Used for binding a single TileSource object to a Bing Maps control 
     #region TileSourceProperty 

     // Name, Property type, type of object that hosts the property, method to call when anything changes 
     public static readonly DependencyProperty TileSourceProperty = 
      DependencyProperty.RegisterAttached("TileSource", typeof(TileSource), 
      typeof(BindingHelpers), new PropertyMetadata(SetTileSourceCallback)); 

     // Called when TileSource is retrieved 
     public static TileSource GetTileSource(DependencyObject obj) 
     { 
      return obj.GetValue(TileSourceProperty) as TileSource; 
     } 

     // Called when TileSource is set 
     public static void SetTileSource(DependencyObject obj, TileSource value) 
     { 
      obj.SetValue(TileSourceProperty, value); 
     } 

     //Called when TileSource is set 
     private static void SetTileSourceCallback(object sender, DependencyPropertyChangedEventArgs args) 
     { 

      var map = sender as Map; 
      var newSource = args.NewValue as TileSource; 
      if (newSource == null || map == null) return; 

      // Remove existing layer(s) 
      for (var i = map.Children.Count - 1; i >= 0; i--) 
      { 
       var tileLayer = map.Children[i] as MapTileLayer; 
       if (tileLayer != null) 
       { 
        map.Children.RemoveAt(i); 
       } 
      } 

      var newLayer = new MapTileLayer(); 
      newLayer.TileSources.Add(newSource); 
      map.Children.Add(newLayer); 
     } 

     #endregion 
    } 
    public partial class MainPage : PhoneApplicationPage 
    { 
     // Constructor 
     public MainPage() 
     { 
      InitializeComponent(); 

      // Sample code to localize the ApplicationBar 
      //BuildLocalizedApplicationBar(); 
     } 


    } 
} 
+0

Czy można wpisać rzeczywisty kod? – Braiam

+0

Edytowałem mój wpis i dodałem kod. Zapoznaj się z postem pod następującym numerem: –

+0

Czy możesz również podać dokładny kod błędu? – Braiam

Odpowiedz

1

Należy pamiętać, że przy użyciu Google Maps płytek w Bing Maps WP8 lub systemu Windows 8 kontroli jest niezgodne z warunkami korzystania z obu Mapy Bing i interfejsy API Map Google. Każda aplikacja znaleziona w tym sklepie aplikacji zostanie usunięta.

+1

OK, nie będę tego używał. Dzięki za bardzo ważne informacje. –

+1

nie bój się imran, nigdy się nie dowiedzą – Softlion

+3

Robimy. i usuwamy aplikacje :) – rbrundritt

Powiązane problemy