Fauzian Sebastian (Zian Tech)
Menu
  • Home
  • TKJ
    • Perakitan
    • Installasi
    • Konfigurasi
    • TroubleHosting
  • Rekayasa Perangkat Lunak
    • WEB Design
    • Software Aplication
  • Multimedia
    • Animation
    • Desain Graphic
  • Trending Topic
  • Tentang Saya

Thursday, 1 January 2015

Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone

By zianovel21:09:00 No comments
Assalamukum agan semua,,,
untuk mengawali hari pertam di tahun 2015 ini :D, saya ingin memposting tentang Windows Phone lagi, kali ini tentang bagaimana cara Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone,
biaasanya cara ini digunakan jika kita ingin membuat tempat pariwisata ataupun yang lainnya..

Langkah - langkah Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone

1. Buat sebuah Project Windows Phone App baru

2. Tambahkan references Windows Phone Toolkit dengan cara klik kanan references > Manage Nuget Packages > Cari Windows Phone Toolkit > Install

Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone



2. Tambahkan 1 map, 2 textbox dan textblock dan buat sebuah application bar

<!--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>

<!-- LOCALIZATION NOTE:
To localize the displayed strings copy their values to appropriately named
keys in the app's neutral language resource file (AppResources.resx) then
replace the hard-coded text value between the attributes' quotation marks
with the binding clause whose path points to that string name.

For example:

Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

This binding points to the template's string resource named "ApplicationTitle".

Adding supported languages in the Project Properties tab will create a
new resx file per language that can carry the translated values of your
UI strings. The binding in these examples will cause the value of the
attributes to be drawn from the .resx file that matches the
CurrentUICulture of the app at run time.
-->

<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.

Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="Tutorial Koding" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="Map" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map x:Name="mymap" HorizontalAlignment="Left" Grid.Row="0" VerticalAlignment="Top" Height="404" Width="456"/>
<TextBlock HorizontalAlignment="Left" Margin="10,429,0,0" TextWrapping="Wrap" Text="Longitude" VerticalAlignment="Top"/>
<TextBox x:Name="txt_longitude" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap" VerticalAlignment="Top" Width="340" Margin="116,404,0,0"/>
<TextBlock HorizontalAlignment="Left" Margin="10,486,0,0" TextWrapping="Wrap" Text="Latitude" VerticalAlignment="Top"/>
<TextBox x:Name="txt_latitude" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap" VerticalAlignment="Top" Width="340" Margin="116,461,0,0"/>
</Grid>
</Grid>

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar Mode="Default" Opacity="1" IsMenuEnabled="True" IsVisible="True">
<shell:ApplicationBarIconButton x:Name="cari" Text="Cari" IconUri="/Assets/AppBar/feature.search.png" Click="cari_Click"/>
<shell:ApplicationBarIconButton x:Name="zoommore" Text="Zoom In" IconUri="/Assets/AppBar1/add.png" Click="zoommore_Click"/>
<shell:ApplicationBarIconButton x:Name="zoomless" Text="Zoom Out" IconUri="/Assets/AppBar2/minus.png" Click="zoomless_Click"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone


3. Buka Capabilities pada file WMAppManifest.xml centang ID_CAP_MAP

Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone

4. Import 4 namespace dibawah ini pada file .xaml anda

using System.Threading.Tasks;
using Windows.Devices.Geolocation;
using Microsoft.Phone.Maps.Toolkit;
using Microsoft.Phone.Maps.Controls;
using System.Windows.Media;

5. Pada event cari_Click tambahkan script dibawah ini

private void cari_Click(object sender, EventArgs e)
{
// Membuat Pushpin
Pushpin mypushpin = new Pushpin();
mypushpin.Content = "Lokasi";

// Menambahkan pushpin ke MapOverlay
MapOverlay myoverlay = new MapOverlay();
myoverlay.Content = mypushpin;
// menyesuaikan koorinate MapOverlay
myoverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(Convert.ToDouble(txt_latitude.Text), Convert.ToDouble(txt_longitude.Text));
myoverlay.PositionOrigin = new Point(0, 0.5);

// tambahkan MapOverlay ke MapLayer
MapLayer mylayer = new MapLayer();
mylayer.Add(myoverlay);

// Menambahkan MapLayer ke map
mymap.Layers.Add(mylayer);
// Mengatur posisi tengah map
mymap.Center = new System.Device.Location.GeoCoordinate(Convert.ToDouble(txt_latitude.Text), Convert.ToDouble(txt_longitude.Text));
mymap.ZoomLevel = 14;
}

6. Pada event zoommore_Click dan zoomless_Click tambahkan script dibawah ini

        private void zoommore_Click(object sender, EventArgs e)
{
// memperbesar map
mymap.ZoomLevel = Math.Min(mymap.ZoomLevel + 1, 20);
}

private void zoomless_Click(object sender, EventArgs e)
{
// memperkecil map
mymap.ZoomLevel = Math.Max(mymap.ZoomLevel - 1, 1);
}

7. Jalankan Aplikasi tersebut dengan menekan F5 maka akan seperti gambar dibawah ini



Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone

Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone

Anda bisa mendownload source codenya disini
dan untuk passwordnya disini

Sekian pembahasan tentang Menampilkan Map Berdasarkan Longitude dan Latitude Windows Phone
Tunggu tutorial menarik lainnya, karena itu kunjungi terus blog ini. . .
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 komentar:

Post a Comment

Popular Posts

  • Mengatasi error "String or binary data would be truncated. The statement has been terminated."
    Malam semua setelah beberapa jam yang lalu saya memposting tentang CRUD dengan VB.NET Bagian 1  kali ini saya akan memposting  C ara mengata...
  • Tutorial Sql Injection Dengan SQLMAP Kali Linux
    Tutorial Sql Injection Dengan SQLMAP Kali Linux - SQL Injection merupakan sebuah teknik hacking dimana seorang penyerang dapat memasukka...
  • Memutuskan Koneksi Orang Lain Dengan Tuxcut Kali Linux
    Memutuskan Koneksi Orang Lain Dengan Tuxcut Kali Linux - Tuxcut adalah sebuah program kecil yang berfungsi ( netcut ) "memotong ...
  • Cara Dual Boot Kali Linux dan Windows
    Kali Linux Indonesia - Cara Install Dual Boot Kali Linux dan Windows halo sobat dimana pun berada disini penulis blog Kali Linux Indonesia...
  • Cara Mengatasi Error di Kali Linux
    Cara Mengatasi Error di Kali Linux - Pernah kah anda mengalami error di kali linux anda? jika pernah pasti menjengkelkan tidak bisa update t...

Blog Archive

  • ►  2020 (1)
    • ►  March (1)
  • ►  2016 (26)
    • ►  October (10)
    • ►  May (1)
    • ►  February (3)
    • ►  January (12)
  • ▼  2015 (35)
    • ►  December (2)
    • ►  October (4)
    • ►  September (18)
    • ►  August (1)
    • ►  June (1)
    • ►  May (2)
    • ►  April (1)
    • ►  March (1)
    • ▼  January (5)
      • Navigasi Halaman dengan Efek Transisi di Windows P...
      • Membuat Context Menu di Wndows Phone
      • Menampilkan Lokasi Device di Map Secara Real Time ...
      • Menampilkan Lokasi Device di Map di Windows Phone
      • Menampilkan Map Berdasarkan Longitude dan Latitude...
  • ►  2014 (99)
    • ►  December (1)
    • ►  November (3)
    • ►  October (1)
    • ►  September (6)
    • ►  August (3)
    • ►  July (3)
    • ►  June (9)
    • ►  May (9)
    • ►  April (27)
    • ►  March (20)
    • ►  February (10)
    • ►  January (7)
  • ►  2013 (17)
    • ►  December (6)
    • ►  November (1)
    • ►  October (9)
    • ►  March (1)

Tentangku Yang tak pernah Usai

My Photo
zianovel
Kenalan dulu yu, karena ada istilah tak kenal maka tak sayang. Ya walaupun terkadang udah lama kenal eh ga disayang-sayang. Giliran udah kenal dan udah sayang, eh malah ditinggal pas lagi sayang-sayangnya.
View my complete profile

Copyright © Design by Muhamad Fauzian