Skip to content

Instantly share code, notes, and snippets.

@eeeschwartz
Last active May 24, 2016 21:08
Show Gist options
  • Save eeeschwartz/436bfe0527be21e9137c4a114edca6ab to your computer and use it in GitHub Desktop.
Save eeeschwartz/436bfe0527be21e9137c4a114edca6ab to your computer and use it in GitHub Desktop.
Lexington address autocomplete
<html>
<head>
<meta charset=utf-8 />
<title>Searching map services</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!-- Load Leaflet from CDN-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.1/leaflet.css" />
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.1/leaflet-src.js"></script>
<!-- Load Esri Leaflet from CDN -->
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.0/esri-leaflet.js"></script>
<style>
body { margin:0; padding:0; }
#map { position: absolute; top:0; bottom:0; right:0; left:0; }
</style>
</head>
<body>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.0/esri-leaflet-geocoder.css">
<script src="https://cdn.jsdelivr.net/leaflet.esri.geocoder/2.1.0/esri-leaflet-geocoder.js"></script>
<div id="map"></div>
<script>
var map = L.map('map').setView([38.029, -84.4947], 13);
L.esri.basemapLayer("Streets").addTo(map);
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
var district = L.esri.featureLayer({
// where: 'DISTRICT=1',
url: "http://maps.lexingtonky.gov/lfucggis/rest/services/political/MapServer/1",
style: function (props) {
return { color: getRandomColor(), weight: 2 };
}
}).addTo(map);
var provider = new L.esri.Geocoding.GeocodeServiceProvider({
url: 'https://lexington-geocode-proxy.herokuapp.com/'
});
var searchControl = L.esri.Geocoding.geosearch({
providers: [
provider
]
}).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment