-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathadminCodes.html
90 lines (83 loc) · 3.12 KB
/
adminCodes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Leaflet Geonames Search Control</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.1.0/leaflet.css" />
<link rel="stylesheet" href="../L.Control.Geonames.css" />
<style>
#Nav li {
display: inline;
margin-left: 10px;
}
</style>
</head>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.1.0/leaflet.js"></script>
<script src="../L.Control.Geonames.js"></script>
<div>
<h2 style="float:left;margin:0;">Admin Codes Example:
<small>Only placenames in specified US (country) and state (adminCode1) are returned</small>
</h2>
<ul id="Nav" style="float:right;list-style-type:none; margin:0;padding:0;">
<li>
<b>Other examples:</b>
</li>
<li>
<a href="basic.html">Basic</a>
</li>
<li>
<a href="bbox.html">Bounding Box</a>
</li>
<li>
<a href="locale.html">Locale</a>
</li>
<li>
<a href="events.html">Events</a>
</li>
<li>
<a href="mobileview.html">Mobile View</a>
</li>
<li>
<a href="postCodes.html">Postal Codes</a>
</li>
</ul>
</div>
<div id="map" style="position: absolute; top: 3em; left:0; bottom:0; right: 0;border-top:2px solid #555;"></div>
<script>
var map = L.map('map').setView([44.07, -118.78], 6);
L.tileLayer('//{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
subdomains: 'abcd',
maxZoom: 10,
minZoom: 2
}).addTo(map);
var stateField = L.Control.extend({
options: {
position: 'topleft'
},
onAdd: function () {
this._container = L.DomUtil.create('div', 'leaflet-state-select leaflet-bar');
this._container.title = 'Select a state';
this._input = L.DomUtil.create('input', '', this._container);
this._input.id = 'state';
this._input.type = 'text';
this._input.placeholder = 'Enter a US state';
return this._container;
}
});
map.addControl(new stateField());
var control = L.control.geonames({
username: 'cbi.test',
adminCodes: {
country: 'us',
adminCode1: function () {
return document.getElementById('state').value
}
}
});
map.addControl(control);
</script>
</body>
</html>