-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestMult.html
266 lines (240 loc) · 10.1 KB
/
TestMult.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html dir="ltr">
<!--script>12.10.2015: "Apply sand box example of search on multiple sources on condo suffix and non condo data, get rid of default geocoder. add google map link, add address display <script-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>ArcGIS API for JavaScript | Search widget with multiple sources</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css">
<style>
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#search {
display: block;
position: absolute;
z-index: 2;
top: 25px;
left: 74px;
}
span.dijit.dijitReset.dijitInline.dijitToggleButton {
display: inline-block;
border: 0;
padding: 0;
vertical-align: middle;
position: absolute;
}
#turnOnOff{
font-family: "arial" ;
font-weight: bolder;
z-index: 50;
backgound-color:#CEDAE6;
border: solid 1px #001B33;
border-radius: 4px;
position: absolute;
top: 50px;
left: 74px;
}
.esriPopup .action.zoomTo { display: none; }
#BasemapToggle {
position: absolute;
bottom: 20px;
left: 20px;
z-index: 45;
}
</style>
</script>
<script src="https://js.arcgis.com/3.15/"></script>
<script>
require([
"esri/map","esri/dijit/BasemapToggle",
"esri/dijit/Search", "esri/layers/FeatureLayer", "dijit/form/ToggleButton","esri/InfoTemplate", "dojo/dom", "dojo/on","esri/tasks/query", "esri/tasks/QueryTask",
"dojo/domReady!"
], function (Map, BasemapToggle, Search, FeatureLayer, ToggleButton,InfoTemplate,dom, on,Query, QueryTask) {
var map = new Map("map", {
basemap: "streets",
center: [-74.005941, 40.712784], // lon, lat
zoom: 17
});
//ArcGIS Online feature service showing Mahattan Tc2 lots
var layer = new FeatureLayer("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/TC2_MH_noncd122015/FeatureServer/0", {
outFields: ["*"],
maxScale:1000,
minScale:5000,
id:'noncd',
infoTemplate: new InfoTemplate("Parcel: ${BORO}/${BLOCK}/${LOT}",
"</br>DOF Value 2016 Tentative: $</b>${fmv:NumberFormat}</br>"
+"</br>Adress:${Street_Num}, ${Street_Nam}, New York, NY</br>"
+"</br>Total Units:${resunit}</br>"
+"</br>Gross SQFT:${ttlsqft} SQFT</br>"
+"</br>Stories:${story:NumberFormat}</br>"
+"</br>Year Built:${AYB}</br>"
+"</br>Residential SQFT:${ressqft} SQFT</br></br>"
+"<div> <a href='http://www1.nyc.gov/site/finance/taxes/property.page' target='_blank'>View Property Tax Bills</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/benefits/property-related-benefits.page' target='_blank'>Exemptions and Abatements</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/taxes/property-forms/property-forms-assessments-and-valuations.page' target='_blank'>Request Data Correction</a></div>"
+"<div> </br><a href='http://maps.google.com/?q=${Street_Num} ${Street_Nam}, new york, ny' target='_blank'>Search on Google Map</a></div>"
)
});
//Condo Suffix layer
var layercdm = new FeatureLayer("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/TC2_MH_cdmain122015/FeatureServer/0", {
outFields: ["*"],
maxScale:1000,
minScale:5000,
id:'cd'
});
//Condo Suffix layer
var layercds = new FeatureLayer("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/mhcdsuff/FeatureServer/0", {
outFields: ["*"],
maxScale:1000,
minScale:5000
});
//Add layers to map
map.addLayers([layer,layercdm]);
//SET UP BASEMAP TOGGLE
var toggle = new BasemapToggle({
map: map,
basemap: "satellite"
}, "BasemapToggle");
toggle.startup();
//Search
var s = new Search({
enableButtonMode: false, //this enables the search widget to display as a single button
enableLabel: true,
enableInfoWindow: true,
showInfoWindowOnSelect: true,
zoomScale: 1000,
allPlaceholder: "Choose search type",
activeSourceIndex:'cd',
enableSearchingAll: false,
map: map
}, "search");
var sources = [];
//Push the sources used to search, by default the ArcGIS Online World geocoder is included. In addition there is a feature layer of US congressional districts. The districts search is set up to find the "DISTRICTID". Also, a feature layer of senator information is set up to find based on the senator name.
sources.push({
featureLayer: new FeatureLayer("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/TC2_MH_noncd1210/FeatureServer/0"),
searchFields: ["bl_sp"],
displayField: "bl_sp",
exactMatch: true,
outFields: ["*"],
name: "Search on nonCondo",
placeholder: "126/27",
maxResults: 3,
maxSuggestions: 3,
//Create an InfoTemplate and include three fields
infoTemplate: new InfoTemplate("Parcel: ${BORO}/${BLOCK}/${LOT}",
"</br>DOF Value 2016 Tentative: $</b>${fmv:NumberFormat}</br>"
+"</br>Adress:${Street_Num}, ${Street_Nam}, New York, NY</br>"
+"</br>Total Units:${resunit}</br>"
+"</br>Gross SQFT:${ttlsqft} SQFT</br>"
+"</br>Stories:${story:NumberFormat}</br>"
+"</br>Year Built:${AYB}</br>"
+"</br>Residential SQFT:${ressqft} SQFT</br></br>"
+"<div> <a href='http://www1.nyc.gov/site/finance/taxes/property.page' target='_blank'>View Property Tax Bills</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/benefits/property-related-benefits.page' target='_blank'>Exemptions and Abatements</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/taxes/property-forms/property-forms-assessments-and-valuations.page' target='_blank'>Request Data Correction</a></div>"
+"<div> </br><a href='http://maps.google.com/?q=${Street_Num} ${Street_Nam}, new york, ny' target='_blank'>Search on Google Map</a></div>"
),
enableSuggestions: true,
minCharacters: 0
});
sources.push({
featureLayer: new FeatureLayer("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/TC2_MH_cdmain122015/FeatureServer/0"),
searchFields: ["CONDO_KEY"],
displayField: "CONDO_KEY",
exactMatch: true,
name: "Search on Condo main",
outFields: ["*"],
placeholder: "1536",
maxResults: 3,
maxSuggestions: 3,
//Create an InfoTemplate
infoTemplate: new InfoTemplate("Parcel: ${CONDO_KEY}",
"<div></br> <a href='http://www1.nyc.gov/site/finance/taxes/property.page' target='_blank'>View Property Tax Bills</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/benefits/property-related-benefits.page' target='_blank'>Exemptions and Abatements</a></div>"
+"<div> <a href='http://www1.nyc.gov/site/finance/taxes/property-forms/property-forms-assessments-and-valuations.page' target='_blank'>Request Data Correction</a></div>"
+"<div> </br><a href='http://maps.google.com/?q=${Street_Num} ${Street_Nam}, new york, ny' target='_blank'>Search on Google Map</a></div>"
+"<div> </br><a href='http://maps.googleapis.com/maps/api/streetview?location=${Street_Num} ${Street_Nam}, new york, ny&size=600x400&fov=360&heading=235&pitch=10' target='_blank'>Google Street View</a></div>"
),
enableSuggestions: true,
minCharacters: 0
});
//Set the sources above to the search widget
s.set("sources", sources);
s.set("activeSourceIndex", 1);
var searchcd;
s.on("search-results", function (e) {
var rs, h;
rs = e.results;
h = "";
if (rs[1] == null){
h = "<div> rs is null</div>";
return;
};
//h = inspect(rs[0][0].feature.attributes, 5, 0);
var attrs = rs[1][0].feature.attributes;
searchcd=attrs.CONDO_KEY;
});
s.startup();
new ToggleButton({
showLabel: true,
onChange: function(val){
if(val == true){
layercdm.setVisibility(false);
layer.setVisibility(true);
this.set('label', 'Show and Search on Condo');
s.set("activeSourceIndex", 0);
}
else{
layercdm.setVisibility(true);
layer.setVisibility(false);
this.set('label', 'Show and Search on non Condo');
s.set("activeSourceIndex", 1);
}
},
label: "Show and Search on non Condo"
}, "turnOnOff");
//Query1216
//Initiate Query
var queryTask = new QueryTask("//services3.arcgis.com/aD88pT4hjL80xq0F/arcgis/rest/services/MHcdsuffix/FeatureServer/0");
var query = new Query();
query.returnGeometry = false;
query.outFields = ["*"]
//Execute Query
on(dom.byId("execute"), "click", execute);
function execute () {
query.where = "CONDO_KEY = "+searchcd ;
queryTask.execute(query, showResults,function(error){console.log(error);});
}
function showResults (results) {
var resultItems = [];
var resultCount = results.features.length;
for (var i = 0; i < resultCount; i++) {
var featureAttributes = results.features[i].attributes;
for (var attr in featureAttributes) {
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
}
resultItems.push("<br>");
}
dom.byId("info").innerHTML = resultItems.join("");
}
});
</script>
</head>
<body>
<!--input type="text" id="blu_sp" value="134/7503/R1"-->
<input id="execute" type="button" value="Get Details">
<button id="turnOnOff">Show and Search on non Condo</button>
<div id="search"></div>
<div id="map">
<div id="BasemapToggle"></div>
</div>
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</body>
</html>