Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initialize() {
- directionsDisplay = new google.maps.DirectionsRenderer();
- var node = new google.maps.LatLng(-7.276442,112.791174);
- var mapOptions = {
- zoom: 15,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- map = new google.maps.Map(document.getElementById('map'),
- mapOptions);
- directionsDisplay.setMap(map);
- navigator.geolocation.getCurrentPosition(function(position) {
- pos = new google.maps.LatLng(position.coords.latitude,
- position.coords.longitude);
- var marker = new google.maps.Marker({
- position : pos,
- map: map,
- title:'Lokasi Anda'
- });
- var marker1 = new google.maps.Marker({
- position : node,
- map: map,
- title:'Lokasi Anda'
- });
- map.setCenter(pos);
- }, function() {
- handleNoGeolocation(true);
- });
- }
- function calcRoute() {
- var request = {
- origin:pos,
- destination:node,
- travelMode: google.maps.DirectionsTravelMode.DRIVING
- };
- directionsService.route(request, function(response, status) {
- if (status == google.maps.DirectionsStatus.OK) {
- directionsDisplay.setDirections(response);
- }
- });
- }
- function calcRoute(pos,node) {
- var directionsService = new google.maps.DirectionsService();
- var request = {
- origin:pos,
- destination:node,
- travelMode: google.maps.DirectionsTravelMode.DRIVING
- };
- directionsService.route(request, function(response, status) {
- if (status == google.maps.DirectionsStatus.OK) {
- directionsDisplay.setDirections(response);
- } else { alert("Directions failed: "+status); }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement