alexa-tracking
Selamat Guest, Agan dapat mencoba tampilan baru KASKUS Masih Kangen Tampilan Sebelumnya
Kategori
Kategori
Home / FORUM / All / Tech / ... / Website, Webmaster, Webdeveloper /
[ASK]Google Direction API ga muncul
1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/556fc0425a51634e518b456d/askgoogle-direction-api-ga-muncul

[ASK]Google Direction API ga muncul

Salam sejahtera agan-agan,
sebelumnya maaf kalo emoticon-Salah Kamar
kalo emoticon-Salah Kamar tolong kasih tau ane harus tanya dimana gan he..
Ane pasang google direction API buat di web ane, awal-awalnya sih lancar, tapi ga tau kenapa tiba2 ga muncul..
bisa minta pencerahan gan? ini javascriptnya :
Code:
[removed]
$(document).ready(function() {
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var tengah = new google.maps.LatLng(-7.333333300000000000, 108.200000000000050000);
var posisi_saya;
var posisi_kuliner = new google.maps.LatLng(<?php echo $wisataDetail['latitude']; ?>, <?php echo $wisataDetail['longitude']; ?>emoticon-Wink;

function initialize() {
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
function getPos(position) {

// get latitude and longitude
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
posisi_saya = latitude + "," + longitude;

// send starting location and destination to goToGoogleMaps function
calcRoute(posisi_saya, posisi_kuliner);

}
function Eror(error) {
var errors = {
1: 'Permission denied',
2: 'Position unavailable',
3: 'Request timeout'
};
alert("Error: " + errors[error.code]);
}
// get user's current position
navigator.geolocation.getCurrentPosition(getPos,Eror,{ accuracy : 1200.4, enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 });
}

// fallback for browsers without geolocation
else {

// get manually entered postcode
posisi_saya = $('.manual-location').val();

// if user has entered a starting location, send starting location and destination to goToGoogleMaps function
if (posisi_saya != '') {
calcRoute(posisi_saya, posisi_kuliner);
}
// else fade in the manual postcode field
else {
$('.no-geolocation').fadeIn();
}

}


directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 14,
center: tengah
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
directionsDisplay.setMap(map);

function calcRoute(posisi_saya, posisi_kuliner) {

var selectedMode = document.getElementById('mode').value;

var request = {
origin: posisi_saya,
destination: posisi_kuliner,
// Note that Javascript allows us to access the constant
// using square brackets and a string value as its
// "property."
travelMode: google.maps.TravelMode[selectedMode]
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
}

google.maps.event.addDomListener(window, 'load', initialize);
});
[removed]


ini kode html nya gan

Code:
<p><b>Mode Perjalanan: </b>
<select id="mode">
<option value="DRIVING">Berkendara</option>
<option value="WALKING">Berjalan kaki</option>
<option value="BICYCLING">Sepeda</option>
<option value="TRANSIT">Transit</option>
</select>
<br></p>
<div id="map-canvas"></div>

Please Help gan emoticon-Sorry
Diubah oleh blessseeker
Beri apresiasi terhadap thread ini Gan!


×
GDP Network
© 2018 KASKUS, PT Darta Media Indonesia. All rights reserved
Ikuti KASKUS di