Minggu, 12 Januari 2020
PHP For Multi Line Multi Marker + Arahan
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Draggable Directions</title>
<style>
#right-panel {
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
#right-panel select, #right-panel input {
font-size: 15px;
}
#right-panel select {
width: 100%;
}
#right-panel i {
font-size: 12px;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
float: left;
width: 63%;
height: 100%;
}
#right-panel {
float: right;
width: 34%;
height: 100%;
}
.panel {
height: 100%;
overflow: auto;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="right-panel">
<p>Total Distance: <span id="total"></span></p>
</div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: {lat: -6.353525, lng: 106.831629}
});
var directionsService = new google.maps.DirectionsService;
var directionsRenderer = new google.maps.DirectionsRenderer({
draggable: true,
map: map,
panel: document.getElementById('right-panel')
});
directionsRenderer.addListener('directions_changed', function() {
computeTotalDistance(directionsRenderer.getDirections());
});
//ui-6.353525, 106.831629:
//PLN -6.167230, 106.725907
//-6.306477, 106.882463
//-6.246414, 106.874909
//-6.168428, 106.827406
var myLatLng1 = new google.maps.LatLng({lat: -6.353525, lng: 106.831629});
var myLatLng2 = new google.maps.LatLng({lat: -6.167230, lng: 106.725907});
//displayRoute('Perth, WA', 'Sydney, NSW', directionsService,directionsRenderer);
displayRoute(myLatLng1, myLatLng2, directionsService,directionsRenderer);
}
function displayRoute(origin, destination, service, display) {
var myLatLng1 = new google.maps.LatLng({lat: -6.306477, lng: 106.882463});
var myLatLng2 = new google.maps.LatLng({lat: -6.246414, lng: 106.874909});
var myLatLng3 = new google.maps.LatLng({lat: -6.168428, lng: 106.827406});
//waypoints: [{location: 'Adelaide, SA'}, {location: 'Broken Hill, NSW'}],
service.route({
origin: origin,
destination: destination,
waypoints: [{location: myLatLng1}, {location: myLatLng2}, {location: myLatLng3}],
travelMode: 'DRIVING',
avoidTolls: true
}, function(response, status) {
if (status === 'OK') {
display.setDirections(response);
} else {
alert('Could not display directions due to: ' + status);
}
});
}
function computeTotalDistance(result) {
var total = 0;
var myroute = result.routes[0];
for (var i = 0; i < myroute.legs.length; i++) {
total += myroute.legs[i].distance.value;
}
total = total / 1000;
document.getElementById('total').innerHTML = total + ' km';
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBhSg6I2JvHNU_jLqIpvc5MEwc_xi3Ttvg&callback=initMap">
</script>
</body>
</html>
REF:
https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/javascript/examples/directions-draggable
https://developers.google.com/maps/documentation/javascript/reference/3.37/coordinates#LatLng
Langganan:
Posting Komentar (Atom)
Selisih Waktu Berjalan
Berikut adalah fungsi PHP yang menghitung selisih hari antara tanggal saat ini dengan tanggal 2024-08-22 . Jika tanggal saat ini kurang dari...
-
<?php // <a href='download.php?file=$file' title='Download File'>Download Dokumen</a> $direktori = ...
-
Teman2 ...mungkin sering dapat kode random..... btw ini ada share sedikit ttg membuat soal random.....yang beda disini adalah sy menggunaka...
-
<?php $sql="select `id_admin` from `$tbadmin` order by `id_admin` desc"; $jum= getJum($conn,$sql); $kd="ADM"...
Tidak ada komentar:
Posting Komentar