Created
May 26, 2016 08:31
-
-
Save kaochenlong/91e88ffc88fd31b0fa1825686e07b065 to your computer and use it in GitHub Desktop.
This file contains 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>新北市 U-Bike 據點</title> | |
<style> | |
html, body { | |
height: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
#map { | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
function initMap() { | |
var map = new google.maps.Map(document.getElementById('map'), { | |
zoom: 14, | |
center: {lat: 25.074629, lng: 121.478162} | |
}); | |
setMarkers(map); | |
} | |
var beaches = <%= locations %>; | |
function setMarkers(map) { | |
var image = { | |
size: new google.maps.Size(20, 32), | |
origin: new google.maps.Point(0, 0), | |
anchor: new google.maps.Point(0, 32) | |
}; | |
var shape = { | |
coords: [1, 1, 1, 20, 18, 20, 18, 1], | |
type: 'poly' | |
}; | |
for (var i = 0; i < beaches.length; i++) { | |
var beach = beaches[i]; | |
var marker = new google.maps.Marker({ | |
position: {lat: beach[1], lng: beach[2]}, | |
map: map, | |
shape: shape, | |
title: beach[0], | |
zIndex: beach[3] | |
}); | |
} | |
} | |
</script> | |
<script async defer | |
src="https://maps.googleapis.com/maps/api/js?key=API_KEY&signed_in=true&callback=initMap"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment