I have a map with 2 Pushpins, when I load the page, I set the location of one of the buttons in the code. However, when I try to reference the output, it is zero.
Xaml
<maps:Map x:Name="mapEventLocation" ZoomLevel="15" Grid.Row="1" Tap="mapEventLocation_Tap" > <maptoolkit:MapExtensions.Children> <maptoolkit:Pushpin x:Name="userLocationPin" Content="You" Visibility="Collapsed" /> <maptoolkit:Pushpin x:Name="eventLocationPin" Content="Event" Visibility="Collapsed" /> </maptoolkit:MapExtensions.Children> </maps:Map>
FROM#
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { if (this.NavigationContext.QueryString.ContainsKey("lat")) { userLocationPin.GeoCoordinate = new GeoCoordinate(double.Parse(this.NavigationContext.QueryString["lat"]), double.Parse(this.NavigationContext.QueryString["lon"])); userLocationPin.Visibility = System.Windows.Visibility.Visible; mapEventLocation.Center = new GeoCoordinate(double.Parse(this.NavigationContext.QueryString["lat"]), double.Parse(this.NavigationContext.QueryString["lon"])); } }
Lat and Lon are definitely in QueryString.
Used before
Pushpin pin = (Pushpin)this.FindName("userLocationPin");
This works for an emulator, but not on a real phone.
I tried to make the pushpins manually in the layer, but the pin goes into a corner
Pushpin userLocation = new Pushpin(); userLocation.GeoCoordinate = new GeoCoordinate(double.Parse(this.NavigationContext.QueryString["lat"]), double.Parse(this.NavigationContext.QueryString["lon"])); userLocation.Content = "You"; MapLayer layer = new MapLayer(); MapOverlay overlay = new MapOverlay(); overlay.Content = userLocation; layer.Add(overlay); mapEventLocation.Layers.Add(layer);
Any ideas would be highly appreciated. Thanks
Seige source share