-
Notifications
You must be signed in to change notification settings - Fork 0
/
share.html
314 lines (280 loc) · 11.9 KB
/
share.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>PLI Parcel Locator</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.8/esri/css/main.css">
<style>
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
var dojoConfig = {
has: {
"esri-featurelayer-webgl": 1
}
};
</script>
<script src="https://js.arcgis.com/4.8/"></script>
<script>
var map;
var parcels;
require([
"esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer",
"esri/tasks/support/Query", "esri/layers/GraphicsLayer",
"esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol",
"esri/renderers/ClassBreaksRenderer",
"esri/Graphic", "esri/widgets/Popup",
"esri/core/urlUtils",
"esri/Color",
"dojo/on", "dojo/query", "dojo/parser", "dojo/dom-construct",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
], function (
Map, MapView, FeatureLayer,
Query, GraphicsLayer,
SimpleFillSymbol, SimpleLineSymbol,
ClassBreaksRenderer,
Graphic, Popup,
urlUtils,
Color,
on, query, parser, domConstruct
) {
parser.parse();
var popup = new Popup({
container: domConstruct.create("div"),
});
var selectionLayer = new GraphicsLayer({
listMode: "hide",
visible: true
});
map = new Map({
layers: [selectionLayer],
basemap: "topo"
});
var view = new MapView({
container: "viewDiv",
map: map,
popup: {
dockEnabled: true,
dockOptions: {
// Disables the dock button from the popup
buttonEnabled: false,
// Ignore the default sizes that trigger responsive docking
breakpoint: false,
}
},
});
var popupTemplate = {
title: 'Owner: {own_name}',
content: "<p><b>Parcel ID:</b> {parcel_id}</p>" +
"<p><b>State Parcel ID:</b> {state_par_}</p>" +
"<p><b>PLI Code:</b> {pli_code}</p>" +
"<p><b>Size:</b> {no_lnd_unt:NumberFormat(places: 2)} Acres<p>" +
"<p><b>Value:</b> ${av_nsd:NumberFormat(places: 2)}</p>" +
"<p><b>TRS:</b> {twn} {rng} {sec}</p>" +
"<p><b>Legal Description:</b> {s_legal}</p>",
actions: [{
id: "Email-Map",
className: "esri-icon-contact",
title: "Email Map"
}],
};
var highlightSymbol = new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([96, 96, 96]), 3);
function createSymbol(color) {
return new SimpleFillSymbol({
color: color,
style: "solid",
outline: {
width: 0.75,
color: [0, 0, 0, 0.2]
}
})
}
var parcelRenderer = new ClassBreaksRenderer({
field: "pli_code",
legendOptions: {
title: "Land Owner Index"
},
classBreakInfos: [{
minValue: 1000,
maxValue: 1999,
label: "State Lands",
symbol: createSymbol("#7fc97f")
}, {
minValue: 2000,
maxValue: 2999,
label: "Volunteer Fire Department Lands",
symbol: createSymbol("#beaed4")
}, {
minValue: 3000,
maxValue: 3999,
label: "Federal Lands",
symbol: createSymbol("#a65628")
}, {
minValue: 4000,
maxValue: 4999,
label: "County Lands",
symbol: createSymbol("#984ea3")
}, {
minValue: 5000,
maxValue: 5999,
label: "Municipal Lands",
symbol: createSymbol("#386cb0")
}, {
minValue: 6000,
maxValue: 6999,
label: "Other or Non-Private Lands",
symbol: createSymbol("#f0027f")
}, {
minValue: 7000,
maxValue: 8999,
label: "Special District Lands",
symbol: createSymbol("#bf5b17")
}]
});
var highlightGraphic;
//add the parcels layer to the map as a feature layer in selection mode we'll use this layer to query and display the selected parcels
// parcels = new FeatureLayer({
// url: "https://admin205.ispa.fsu.edu/arcgis/rest/services/PLI/PLI_2017/MapServer/0",
// outFields: ["*"],
// popupTemplate: popupTemplate,
// renderer: parcelRenderer
// });
parcels = new FeatureLayer({
url: "https://maps.freac.fsu.edu/arcgis/rest/services/PLI/PLI/MapServer/0",
outFields: ["*"],
popupTemplate: popupTemplate,
renderer: parcelRenderer
});
// var parcelsLayerURL = "https://maps.freac.fsu.edu/arcgis/rest/services/PLI/PLI/MapServer/";
// var parcels = new MapImageLayer({
// url: parcelsLayerURL,
// title: "Parcels Layer",
// sublayers: [{
// id: 0,
// title: "State Agencies",
// visible: true,
// minScale: 150000,
// renderer: parcelRenderer
// }]
// });
query(view).on('click', function (response) {
view.graphics.removeAll();
selectionLayer.graphics.removeAll();
});
view.when(function () {
// Watch for when features are selected
view.popup.watch("selectedFeature", function (graphic) {
if (graphic) {
var parcel_id = graphic.attributes["parcel_id"];
//Refresh the URL with the currently selected parcel
if (typeof history.pushState !== "undefined") {
window.history.pushState(null, null, "?parcel_id=" + graphic.attributes
.parcel_id);
highlightGraphic = new Graphic(graphic.geometry,
highlightSymbol);
selectionLayer.graphics.add(highlightGraphic);
}
}
});
});
view.when(function () {
var popup = view.popup;
popup.viewModel.on("trigger-action", function (event) {
if (event.action.id === "Email-Map") {
var attributes = popup.viewModel.selectedFeature.attributes;
// Get the 'parcel_id' field attribute
var info = attributes.parcel_id;
// Make sure the 'parcel_id' field value is not null
if (info) {
var url = window.location;
var emailLink = "mailto:?subject=Parcel Map of :" +
info + "&body=Check out this map: %0D%0A " +
window.location;
window.location.href = emailLink;
}
}
});
});
parcels.when(function () {
// Add a link into the InfoWindow Actions panel
var emailLink = domConstruct.create("a", {
"class": "action",
"innerHTML": "Email Map",
"href": "javascript:void(0);"
}, query(".actionList", view.popup.domNode)[0]);
//When users navigate through the history using the browser back/forward buttons select appropriate parcel
//http://developer.mozilla.org/en/DOM/Manipulating_the_browser_history
window.onpopstate = function (event) {
var parcel_id = getParcelFromUrl(document.location.href);
if (parcel_id) {
selectParcel(parcel_id);
} else {
//parcels.clearSelection();
view.popup.close();
}
};
//if a parcel_id is specified in url param select that feature
var parcel_id = getParcelFromUrl(document.location.href);
selectParcel(parcel_id);
});
map.add(parcels);
map.reorder(parcels, 0)
//extract the parcel id from the url
function getParcelFromUrl(url) {
var urlObject = urlUtils.urlToObject(url);
if (urlObject.query && urlObject.query.parcel_id) {
return urlObject.query.parcel_id;
} else {
return null;
}
}
//select parcel from the feature layer by creating a query to look for the input parcel id
function selectParcel(parcel_id) {
if (parcel_id) {
var query = parcels.createQuery();
query.where = "parcel_id = '" + parcel_id + "'";
var deferred = parcels.queryFeatures(query).then(function (selection) {
// add graphic to selectionLayer when parcel selected
selectionLayer.graphics.removeAll();
highlightGraphic = new Graphic(selection.features[0].geometry,
highlightSymbol);
selectionLayer.graphics.add(highlightGraphic);
var center = selection.features[0].geometry.extent.center;
var extHandler = view.watch("stationary", function () {
extHandler.remove();
//zoom to the center then display the popup
view.popup.open({
features: selection.features,
updateLocationEnabled: true
});
});
// Zoom to feature
var ext = selection.features[0].geometry.extent;
var cloneExt = ext.clone();
view.goTo({
target: selection.features[0],
extent: cloneExt.expand(1.75)
});
});
}
}
});
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width: 100%; height: 100%; margin: 0;">
<div id="viewDiv" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
</body>
</html>