View esri-leaflet-identify-example.js
// this function is called on map click event
showEntities: function(latLng) {
try {
cwns.map.removeLayer(cwns.current.selectedGeoJson);
cwns.current.countyGroupLayer.clearLayers();
cwns.current.congDistGroupLayer.clearLayers();
cwns.current.stateGroupLayer.clearLayers();
cwns.mapMarker.setLatLng(latLng);
cwns.map.addLayer(cwns.mapMarker);
cwns.cwnsDynamicLayer.identify()
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>One Minute Map</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>
#map {
height: 100%;
View population-io-country-translator.json
[{"Country":"Falkland Islands","populationIoName":"NotFound","iso2Code":"FK"},{"Country":"French Guiana","populationIoName":"French Guiana","iso2Code":"GF"},{"Country":"Guyana","populationIoName":"Guyana","iso2Code":"GY"},{"Country":"Cyprus","populationIoName":"Cyprus","iso2Code":"CY"},{"Country":"Pitcairn","populationIoName":"NotFound","iso2Code":"PN"},{"Country":"South Georgia","populationIoName":"NotFound","iso2Code":"GS"},{"Country":"Saint Helena","populationIoName":"NotFound","iso2Code":"SH"},{"Country":"Egypt","populationIoName":"Arab Rep of Egypt","iso2Code":"EG"},{"Country":"Suriname","populationIoName":"Suriname","iso2Code":"SR"},{"Country":"Georgia","populationIoName":"Georgia","iso2Code":"GE"},{"Country":"Greece","populationIoName":"Greece","iso2Code":"GR"},{"Country":"Trinidad and Tobago","populationIoName":"Trinidad and Tobago","iso2Code":"TT"},{"Country":"Lebanon","populationIoName":"Lebanon","iso2Code":"LB"},{"Country":"Syria","populationIoName":"Syrian Arab Rep","iso2Code":"SY"},{"Country":"Ve
View typeahead-stype.css
.typeahead {
background-color: #FFFFFF;
}
.tt-dropdown-menu {
background-color: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 4px 4px 4px 4px;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
margin-top: 4px;
padding: 4px 0;
View typeahead-event.js
.on("typeahead:selected", function (obj, datum) {
// what happens when a user selects\clicks a suggestion
// we get the datum that contains the properties we defined when we setup the engine via the filter function
map.graphics.clear();
switch(datum.source) {
case "esri-geocoder":
var url = config.arcgisGeocodingBaseUrl + "find?" +
"magicKey=" + datum.magicKey + "&text=" + datum.name +
"&outFields=Addr_type&f=json";
// https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find.htm
View typeahead-all.js
$("#searchInput").typeahead({
// how many characters does the user type before suggestions start firing
minLength: 3,
highlight: true,
hint: false
}, {
name: "camp",
displayKey: "name",
source: campBH.ttAdapter(),
// what the header looks like for this source in the suggestions drop down
View camp-ahead-setup.js
...
, {
name: "camp",
displayKey: "name",
source: campBH.ttAdapter(),
// what the header looks like for this source in the suggestions drop down
templates: {
header: "<h1 class='typeahead-header'><span class='icon icon-camp'></span>&nbsp;Campgrounds</h1>"
}
},
View setup-typeahead.js
$("#searchInput").typeahead({
minLength: 3,
highlight: true,
hint: false
},
View geocode-ahead.js
// build the esri geocoder bloodhound engine
var esriBH = new Bloodhound({
name: "esri-geocoder",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
//https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm
// use the searchExtent parameter to limit the results to roughly washington state
View camp-ahead.js
// https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md#options
var campBH = new Bloodhound({
name: "camp",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.name);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
// feature services currently only support query