Skip to content

Instantly share code, notes, and snippets.

@nickpeihl
Last active December 5, 2017 16:53
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 nickpeihl/f37c81e311158cccbb32 to your computer and use it in GitHub Desktop.
Save nickpeihl/f37c81e311158cccbb32 to your computer and use it in GitHub Desktop.
Debug custom geocoder without Arcgis Online Geocode Service
<!DOCTYPE html>
<html>
<head>
<title>Esri Leaflet Geocoder</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<!-- Load Leaflet from their CDN -->
<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" />
<script src="../node_modules/leaflet/dist/leaflet-src.js"></script>
<script src="../node_modules/esri-leaflet/dist/esri-leaflet.js"></script>
<link rel="stylesheet" href="../src/esri-leaflet-geocoder.css" />
<script src="../src/EsriLeafletGeocoding.js"></script>
<script src="../src/Tasks/Geocode.js"></script>
<script src="../src/Tasks/ReverseGeocode.js"></script>
<script src="../src/Tasks/Suggest.js"></script>
<script src="../src/Services/Geocoding.js"></script>
<script src="../src/Controls/Geosearch.js"></script>
<script src="../src/Providers/ArcgisOnlineGeocoder.js"></script>
<script src="../src/Providers/FeatureLayer.js"></script>
<script src="../src/Providers/GeocodeService.js"></script>
<script src="../src/Providers/MapService.js"></script>
<!-- Make the map fill the entire page -->
<style>
#map {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map('map').setView([37.74, -121.62], 9);
var tiles = L.esri.basemapLayer('Topographic').addTo(map);
L.esri.Geocoding.Controls.geosearch({
providers: [
new L.esri.Geocoding.Controls.Geosearch.Providers.FeatureLayer({
url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2',
searchFields: ['NAME', 'STATE_NAME'],
label: 'US Counties',
formatSuggestion: function(feature){
return feature.properties.NAME;
}
}),
new L.esri.Geocoding.Controls.Geosearch.Providers.GeocodeService({
url: 'http://sjcgis.org/arcgis/rest/services/Tools/Polaris_Geolocator/GeocodeServer',
label: 'Polaris Geocoder',
proxy: 'http://sjcgis.org/proxy/proxy.ashx'
})
],
useArcgisWorldGeocoder: false,
position: 'topright',
useMapBounds: false
}).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment