Created
January 15, 2014 11:25
-
-
Save myamamic/8434599 to your computer and use it in GitHub Desktop.
[gtuggirls] GTUG Girls #15 サンプル4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<meta charset="utf-8" /> | |
<title>Directions service</title> | |
<style> | |
html, body, #map-canvas { | |
height: 100%; | |
margin: 0px; | |
padding: 0px | |
} | |
</style> | |
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
<script> | |
var srcLatLng = new google.maps.LatLng(35.665990, 139.711517); | |
var dstLatLng = new google.maps.LatLng(35.6708529, 139.7605315); | |
var directionsDisplay; | |
var directionsService = new google.maps.DirectionsService(); | |
var map; | |
function initialize() { | |
directionsDisplay = new google.maps.DirectionsRenderer(); | |
var mapOptions = { | |
zoom:16, | |
center: srcLatLng | |
} | |
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); | |
directionsDisplay.setMap(map); | |
calcRoute(); | |
} | |
function calcRoute() { | |
var request = { | |
origin:srcLatLng, | |
destination:dstLatLng, | |
travelMode: google.maps.TravelMode.DRIVING | |
}; | |
directionsService.route(request, function(response, status) { | |
if (status == google.maps.DirectionsStatus.OK) { | |
directionsDisplay.setDirections(response); | |
} | |
}); | |
} | |
google.maps.event.addDomListener(window, 'load', initialize); | |
</script> | |
</head> | |
<body> | |
<div id="map-canvas"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment