Created
February 2, 2017 01:59
-
-
Save rfriberg/8cad1da5499067d68c08c7c505e6bd99 to your computer and use it in GitHub Desktop.
Campus Map | The mapzen.js geocoder
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 lang="en"> | |
<head> | |
<title>Campus Map | The mapzen.js geocoder</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="https://mapzen.com/js/mapzen.css"> | |
<script src="https://mapzen.com/js/mapzen.min.js"></script> | |
<style> | |
html,body{margin: 0; padding: 0} | |
#map { | |
height: 100%; | |
width: 100%; | |
position: absolute; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
// Mapzen API key (replace key with your own) | |
// To generate your own key, go to https://mapzen.com/developers/ | |
L.Mapzen.apiKey = 'mapzen-JA21Wes'; | |
var umn = [44.9745, -93.2346]; | |
var southWest = L.latLng(44.96289, -93.24696), | |
northEast = L.latLng(44.99170, -93.16660), | |
umnBounds = L.latLngBounds(southWest, northEast); | |
var map = L.Mapzen.map('map', { | |
center: umn, | |
zoom: 16, | |
tangramOptions: { | |
scene: L.Mapzen.BasemapStyles.CinnabarMoreLabels | |
} | |
}); | |
// Create custom icon | |
var myIcon = L.icon({ | |
iconUrl: 's3.amazonaws.com/mapzen-assets/images/mapzen-js-geocoder/mn_icon.png', | |
iconSize: [40, 40], | |
popupAnchor: [0, -20] | |
}); | |
var markerOptions = { | |
icon: myIcon | |
}; | |
// Define geocoder options | |
var geocoderOptions = { | |
bounds: umnBounds, | |
layers: ['venue'], | |
markers: markerOptions | |
}; | |
// Instantiate the geocoder (a.k.a the search box) | |
var geocoder = L.Mapzen.geocoder(geocoderOptions); | |
// Add geocoder to map | |
geocoder.addTo(map); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment