Map - Windows Phone Controls |
Map - Windows Phone Controls สำหรับ Map เป็น Controls บน Windows Phone ที่ใช้สำหรับการสร้าง Map หรือแผนที่ในรูปแบบต่าง ๆ
XAML
<Map>
Children
</Map>
Example ตัวอย่างการใช้ Map บน Windows Phone แบบง่าย ๆ
XAML
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="1 0 0 0">
<my2:Map Height="462" HorizontalAlignment="Left" Margin="6,6,0,0" Name="map1" VerticalAlignment="Top" Width="444" />
<Button Content="Zoom In" Height="72" HorizontalAlignment="Left" Margin="6,535,0,0" Name="buttonZoomIn" VerticalAlignment="Top" Width="207" Click="buttonZoomIn_Click" />
<Button Content="Road Mode" Height="72" HorizontalAlignment="Left" Margin="6,474,0,0" Name="buttonRoad" VerticalAlignment="Top" Width="207" Click="buttonRoad_Click" />
<Button Content="Zoom Out" Height="72" HorizontalAlignment="Left" Margin="243,535,0,0" Name="buttonZoomOut" VerticalAlignment="Top" Width="207" Click="buttonZoomOut_Click" />
<Button Content="Aerial Mode" Height="72" HorizontalAlignment="Left" Margin="243,474,0,0" Name="buttonAerial" VerticalAlignment="Top" Width="207" Click="buttonAerial_Click" />
</Grid>
</Grid>
VB.NET
Private Sub buttonRoad_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
map1.Mode = New RoadMode()
End Sub
Private Sub buttonAerial_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
map1.Mode = New AerialMode()
End Sub
Private Sub buttonZoomIn_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Dim zoom As Double
zoom = map1.ZoomLevel
zoom = zoom + 1
map1.ZoomLevel = zoom
End Sub
Private Sub buttonZoomOut_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Dim zoom As Double
zoom = map1.ZoomLevel
zoom = zoom - 1
map1.ZoomLevel = zoom
End Sub
C#
private void buttonRoad_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
map1.Mode = new RoadMode();
}
private void buttonAerial_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
map1.Mode = new AerialMode();
}
private void buttonZoomIn_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
double zoom = 0;
zoom = map1.ZoomLevel;
zoom = zoom + 1;
map1.ZoomLevel = zoom;
}
private void buttonZoomOut_Click(System.Object sender, System.Windows.RoutedEventArgs e)
{
double zoom = 0;
zoom = map1.ZoomLevel;
zoom = zoom - 1;
map1.ZoomLevel = zoom;
}
Screenshot
แสดง Map บน Windows Phone App
|