Skip to content

Instantly share code, notes, and snippets.

@rfriberg
Created February 2, 2017 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfriberg/8cad1da5499067d68c08c7c505e6bd99 to your computer and use it in GitHub Desktop.
Save rfriberg/8cad1da5499067d68c08c7c505e6bd99 to your computer and use it in GitHub Desktop.
Campus Map | The mapzen.js geocoder
<!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