SlideShare une entreprise Scribd logo
1  sur  15
Kelompok 5, MCC-10-01
Rich Internet Application
Deskripsi
0 Pemanfaatan Google Maps API dalam website
0 Fitur yang dimanfaatkan:
   0 Menampilkan map
   0 Menampilkan rute dan detail tujuan (dari asal sampai
     tujuan)
   0 Draggable route
   0 Contoh pembuatan route angkot (custom route)
Tampilan Awal
HTML
Secara garis besar map tersebut terbagi 3 bagian, yaitu:

 1. canvas, untuk menggambar peta
  <div id="map_canvas" style="float:left;width:70%; height:90%"></div>




 2. directions panel, untuk menampilkan petunjuk perjalanan
  <div id="directionsPanel" style="float:right;width:30%;height:90%;overflow:auto;">
  </div>
3. control panel, untuk memilih asal, tujuan, dan mode travel
<div id="control" style="width:60%">
      <strong> Start: </strong>
      <select id="start">
        <option value="Bandung, West Java">Bandung</option>
        <option value="Jakarta">Jakarta</option>
        <option value="Politeknik Telkom">Politeknik Telkom, Bandung</option>
        <option value="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia">Mall Ratu Indah,
   Makassar</option>
        <option value="Jalan Racing Centre 2, Makassar">Jalan Racing Centre 2, Makassar</option>
        <option value="Wigram Road, Forest Lodge, New South Wales, Australia">Wigram Road, Australia</option>
      </select>
      <strong> End: </strong>
      <select id="end">
        <option value="Bandung, West Java">Bandung</option>
        <option value="Jakarta">Jakarta</option>
        <option value="Politeknik Telkom, Bandung">Politeknik Telkom, Bandung</option>
        <option value="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia">Mall Ratu Indah,
   Makassar</option>
        <option value="Jalan Racing Centre 2, Makassar">Jalan Racing Centre 2, Makassar</option>
        <option value="Wilson Street, Newtown, New South Wales, Australia">Wilson Street, Australia</option>
      </select>
      <strong> Mode of Travel: </strong>
      <select id="mode">
        <option value="DRIVING">Driving</option>
        <option value="WALKING">Walking</option>
        <option value="BICYCLING">Bicycling</option>
        <option value="TRANSIT">Transit</option>
        <option value="ANGKOT">Angkot</option>
      </select>
      <input type="button" onClick="calcRoute();" value="Submit"/>
</div>
Script
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDo3H2Vp8EMjfOtP5k
jyyrtC9zX83******&sensor=true"></script>

Kode unik yang bergaris bawah merupakan API Key dan akan berbeda tiap akun
  Google
sensor mengindikasikan apakah aplikasi menggunakan GPS untuk menentukan
  lokasi pengguna atau tidak

var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var politel = new google.maps.LatLng(-6.974990000000001,
107.63114599999994);


DirectionsService bertanggungjawab dalam menentukan jalur.
Variabel politel berisikan latitude-longitude satu tempat; Politeknik Telkom
Inisialisasi dan Opsi Map
function initialize() {
   var rendererOptions = {
   draggable: true
   };

   directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);

   var mapOptions = {
     zoom: 15,
     mapTypeId: google.maps.MapTypeId.ROADMAP,
     center: politel
   }



draggable:true membuat rute pada map dapat diubah
DirectionsRenderer berfungsi untuk menghubungkan awal dan tujuan, juga
waypoints
Tipe Map
0 MapTypeId.ROADMAP   menampilkan   map   tipe
  jalanan
0 MapTypeId.SATELLITE menampilkan gambar dari
  satelit
0 MapTypeId.HYBRID gabungan dari ROADMAP dan
  SATELLITE
0 MapTypeId.TERRAIN menampilkan map fisikal
  berdasarkan informasi daratan
map = new google.maps.Map(document.getElementById("map_canvas"),
 mapOptions);

  directionsDisplay.setMap(map);

 directionsDisplay.setPanel(document.getElementById("directionsPanel")
 );
 } //end of initialize



Kode di atas berfungsi untuk menggambar map pada map_canvas dan
menampilkan panel petunjuk jalan pada directionsPanel
Fungsi Menghitung Jarak
function calcRoute() {
     var start = document.getElementById("start").value;
     var end = document.getElementById("end").value;
     var selectedMode = document.getElementById("mode").value;

        if (start=="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia" && end == "Jalan Racing Centre 2, Makassar" &&
   selectedMode=="ANGKOT"){
        var requestAngkot = {
         origin: start,
         destination: end,
         waypoints:[{location: "Jalan Jenderal Sudirman, Makassar, South Sulawesi, Indonesia"}, {location: "Jalan Pangeran Diponegoro,
   Makassar, South Sulawesi"}, {location: "Jalan Jenderal Urip Sumohardjo, Makassar, South Sulawesi, Indonesia"}, {location: "Jalan Racing
   Centre 2, Makassar, South Sulawesi, Indonesia"}],
         travelMode: google.maps.TravelMode.DRIVING
                };
                  directionsService.route(requestAngkot, function(response, status) {
                   if (status == google.maps.DirectionsStatus.OK) {
                     directionsDisplay.setDirections(response);
                   }
                  });
                }




Kode di atas berfungsi untuk menggambarkan jalur khusus angkot JIKA
awal(start) = “Mal Ratu Indah”, tujuan(end)=“Jalan Racing Centre 2, Makassar”
dan travel mode(selectedMode)=“Angkot”
Waypoints digunakan sebagai titik pemberhentian
 yang diset secara manual

travelMode diset ke DRIVING, karena travel mode
 itulah yang paling mendekati tipe “Angkot”

Setelah route yang dikirim ke DirectionsService
  diterima dan menghasilkan respon “OK”, barulah rute
  akan digambarkan di map

Fungsi calcRoute()akan dijalankan bila tombol
 “Submit” pada Control Panel ditekan
else {
     var request = {
           origin: start,
           destination: end,
           travelMode: google.maps.TravelMode[selectedMode]
     };
     directionsService.route(request, function(response, status) {
         if (status == google.maps.DirectionsStatus.OK) {
           directionsDisplay.setDirections(response);
         }
     });
     }
} //end of calcRoute



Jika start, end dan travelMode tidak sesuai dengan kondisi if, maka value
yang ada akan dijalankan seperti biasa tanpa waypoints dan rute akan
digambarkan jika respon yang dikembalikan adalak “OK”.
Catatan
0 Untuk    mendapatkan Google API Key, silakan
  kunjungi: https://code.google.com/apis/console/
0 Untuk mendapatkan Latitude-Longitude, kami
  menggunakan HTML geocoding yang telah kami
  buat di file terpisah: http://bit.ly/getLatLng
0 Location / value alamat pada program ini
  menggunakan sistem address dan bukan LatLng
0 Full  code:  http://db.tt/SHaOXtmV    (ubah
 “YOUR_KEY_HERE” pada kode menjadi Google API
 Key Anda)
Referensi
0 https://developers.google.com/maps/documentation
  /javascript/directions
0 https://developers.google.com/maps/documentation
  /javascript/geocoding
Akhir
slide

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

En vedette (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Google Maps API untuk Aplikasi Rute Angkot

  • 1. Kelompok 5, MCC-10-01 Rich Internet Application
  • 2. Deskripsi 0 Pemanfaatan Google Maps API dalam website 0 Fitur yang dimanfaatkan: 0 Menampilkan map 0 Menampilkan rute dan detail tujuan (dari asal sampai tujuan) 0 Draggable route 0 Contoh pembuatan route angkot (custom route)
  • 4. HTML Secara garis besar map tersebut terbagi 3 bagian, yaitu: 1. canvas, untuk menggambar peta <div id="map_canvas" style="float:left;width:70%; height:90%"></div> 2. directions panel, untuk menampilkan petunjuk perjalanan <div id="directionsPanel" style="float:right;width:30%;height:90%;overflow:auto;"> </div>
  • 5. 3. control panel, untuk memilih asal, tujuan, dan mode travel <div id="control" style="width:60%"> <strong> Start: </strong> <select id="start"> <option value="Bandung, West Java">Bandung</option> <option value="Jakarta">Jakarta</option> <option value="Politeknik Telkom">Politeknik Telkom, Bandung</option> <option value="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia">Mall Ratu Indah, Makassar</option> <option value="Jalan Racing Centre 2, Makassar">Jalan Racing Centre 2, Makassar</option> <option value="Wigram Road, Forest Lodge, New South Wales, Australia">Wigram Road, Australia</option> </select> <strong> End: </strong> <select id="end"> <option value="Bandung, West Java">Bandung</option> <option value="Jakarta">Jakarta</option> <option value="Politeknik Telkom, Bandung">Politeknik Telkom, Bandung</option> <option value="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia">Mall Ratu Indah, Makassar</option> <option value="Jalan Racing Centre 2, Makassar">Jalan Racing Centre 2, Makassar</option> <option value="Wilson Street, Newtown, New South Wales, Australia">Wilson Street, Australia</option> </select> <strong> Mode of Travel: </strong> <select id="mode"> <option value="DRIVING">Driving</option> <option value="WALKING">Walking</option> <option value="BICYCLING">Bicycling</option> <option value="TRANSIT">Transit</option> <option value="ANGKOT">Angkot</option> </select> <input type="button" onClick="calcRoute();" value="Submit"/> </div>
  • 6. Script <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDo3H2Vp8EMjfOtP5k jyyrtC9zX83******&sensor=true"></script> Kode unik yang bergaris bawah merupakan API Key dan akan berbeda tiap akun Google sensor mengindikasikan apakah aplikasi menggunakan GPS untuk menentukan lokasi pengguna atau tidak var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; var politel = new google.maps.LatLng(-6.974990000000001, 107.63114599999994); DirectionsService bertanggungjawab dalam menentukan jalur. Variabel politel berisikan latitude-longitude satu tempat; Politeknik Telkom
  • 7. Inisialisasi dan Opsi Map function initialize() { var rendererOptions = { draggable: true }; directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions); var mapOptions = { zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP, center: politel } draggable:true membuat rute pada map dapat diubah DirectionsRenderer berfungsi untuk menghubungkan awal dan tujuan, juga waypoints
  • 8. Tipe Map 0 MapTypeId.ROADMAP menampilkan map tipe jalanan 0 MapTypeId.SATELLITE menampilkan gambar dari satelit 0 MapTypeId.HYBRID gabungan dari ROADMAP dan SATELLITE 0 MapTypeId.TERRAIN menampilkan map fisikal berdasarkan informasi daratan
  • 9. map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById("directionsPanel") ); } //end of initialize Kode di atas berfungsi untuk menggambar map pada map_canvas dan menampilkan panel petunjuk jalan pada directionsPanel
  • 10. Fungsi Menghitung Jarak function calcRoute() { var start = document.getElementById("start").value; var end = document.getElementById("end").value; var selectedMode = document.getElementById("mode").value; if (start=="Mal Ratu Indah, Jalan Doktor Sam Ratulangi, Mariso, Indonesia" && end == "Jalan Racing Centre 2, Makassar" && selectedMode=="ANGKOT"){ var requestAngkot = { origin: start, destination: end, waypoints:[{location: "Jalan Jenderal Sudirman, Makassar, South Sulawesi, Indonesia"}, {location: "Jalan Pangeran Diponegoro, Makassar, South Sulawesi"}, {location: "Jalan Jenderal Urip Sumohardjo, Makassar, South Sulawesi, Indonesia"}, {location: "Jalan Racing Centre 2, Makassar, South Sulawesi, Indonesia"}], travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(requestAngkot, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } Kode di atas berfungsi untuk menggambarkan jalur khusus angkot JIKA awal(start) = “Mal Ratu Indah”, tujuan(end)=“Jalan Racing Centre 2, Makassar” dan travel mode(selectedMode)=“Angkot”
  • 11. Waypoints digunakan sebagai titik pemberhentian yang diset secara manual travelMode diset ke DRIVING, karena travel mode itulah yang paling mendekati tipe “Angkot” Setelah route yang dikirim ke DirectionsService diterima dan menghasilkan respon “OK”, barulah rute akan digambarkan di map Fungsi calcRoute()akan dijalankan bila tombol “Submit” pada Control Panel ditekan
  • 12. else { var request = { origin: start, destination: end, travelMode: google.maps.TravelMode[selectedMode] }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } } //end of calcRoute Jika start, end dan travelMode tidak sesuai dengan kondisi if, maka value yang ada akan dijalankan seperti biasa tanpa waypoints dan rute akan digambarkan jika respon yang dikembalikan adalak “OK”.
  • 13. Catatan 0 Untuk mendapatkan Google API Key, silakan kunjungi: https://code.google.com/apis/console/ 0 Untuk mendapatkan Latitude-Longitude, kami menggunakan HTML geocoding yang telah kami buat di file terpisah: http://bit.ly/getLatLng 0 Location / value alamat pada program ini menggunakan sistem address dan bukan LatLng 0 Full code: http://db.tt/SHaOXtmV (ubah “YOUR_KEY_HERE” pada kode menjadi Google API Key Anda)
  • 14. Referensi 0 https://developers.google.com/maps/documentation /javascript/directions 0 https://developers.google.com/maps/documentation /javascript/geocoding