Created
April 30, 2015 21:06
-
-
Save anonymous/fca4871e844b354859c8 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/jajayefazi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html dir="ltr"> | |
<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></title> | |
<link rel="stylesheet" href="http://js.arcgis.com/3.13/dijit/themes/claro/claro.css"> | |
<link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css"> | |
<style> | |
html, | |
body, | |
#map { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
</style> | |
<script src="http://js.arcgis.com/3.13/"></script> | |
<script> | |
require([ | |
"esri/map", | |
"esri/layers/FeatureLayer", | |
"esri/dijit/PopupTemplate", | |
"esri/urlUtils", | |
"esri/dijit/Search", | |
"dojo/domReady!" | |
], function (Map, FeatureLayer,PopupTemplate, urlUtils, Search) { | |
var map = new Map("map", { | |
basemap: "gray", | |
center: [-83.28182100295875, 42.57476998104756], // lon, lat | |
zoom: 16 | |
}); | |
var template = new PopupTemplate({ | |
title: "Parcels", | |
fieldInfos: [{ | |
fieldName: "SITEADDRESS", | |
label: "Address", | |
visible: true | |
},{ | |
fieldName: "OWNERNME1", | |
label: "Owner", | |
visible: true | |
}] | |
}); | |
var layer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2",{ | |
outFields: ["LOWPARCELID","SITEADDRESS","OWNERNME1"], | |
infoTemplate: template | |
}); | |
map.addLayer(layer); | |
//Get the url parameter that identifies the parcel to display | |
var urlObject = urlUtils.urlToObject(document.location.href); | |
var parcel = null; | |
if(urlObject.query && urlObject.query.parcel){ | |
parcel = urlObject.query.parcel; | |
} | |
//Get the url parameter that identifies the parcel to display | |
var urlObject = urlUtils.urlToObject(document.location.href); | |
var parcel = null; | |
if(urlObject.query && urlObject.query.parcel){ | |
parcel = urlObject.query.parcel; | |
} | |
//If the parcel url parameter exists create search widget | |
//and search for parcel using the provided id | |
if(parcel){ | |
var parcelSearch = new Search({ | |
map: map | |
}); | |
//Specify the feature layer and the attribute field to search | |
var source = { | |
exactMatch: true, | |
outFields: ["LOWPARCELID","SITEADDRESS","OWNERNME1"], | |
featureLayer: layer, | |
infoTemplate: template, | |
searchFields: ["LOWPARCELID"] | |
}; | |
parcelSearch.set("sources", [source]); | |
parcelSearch.on("load", function(){ | |
parcelSearch.search(parcel); | |
}); | |
parcelSearch.startup(); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html dir="ltr"> | |
<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></title> | |
<link rel="stylesheet" href="http://js.arcgis.com/3.13/dijit/themes/claro/claro.css"> | |
<link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css"> | |
<style> | |
html, | |
body, | |
#map { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
</style> | |
<script src="http://js.arcgis.com/3.13/"><\/script> | |
<script> | |
require([ | |
"esri/map", | |
"esri/layers/FeatureLayer", | |
"esri/dijit/PopupTemplate", | |
"esri/urlUtils", | |
"esri/dijit/Search", | |
"dojo/domReady!" | |
], function (Map, FeatureLayer,PopupTemplate, urlUtils, Search) { | |
var map = new Map("map", { | |
basemap: "gray", | |
center: [-83.28182100295875, 42.57476998104756], // lon, lat | |
zoom: 16 | |
}); | |
var template = new PopupTemplate({ | |
title: "Parcels", | |
fieldInfos: [{ | |
fieldName: "SITEADDRESS", | |
label: "Address", | |
visible: true | |
},{ | |
fieldName: "OWNERNME1", | |
label: "Owner", | |
visible: true | |
}] | |
}); | |
var layer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer/2",{ | |
outFields: ["LOWPARCELID","SITEADDRESS","OWNERNME1"], | |
infoTemplate: template | |
}); | |
map.addLayer(layer); | |
//Get the url parameter that identifies the parcel to display | |
var urlObject = urlUtils.urlToObject(document.location.href); | |
var parcel = null; | |
if(urlObject.query && urlObject.query.parcel){ | |
parcel = urlObject.query.parcel; | |
} | |
//Get the url parameter that identifies the parcel to display | |
var urlObject = urlUtils.urlToObject(document.location.href); | |
var parcel = null; | |
if(urlObject.query && urlObject.query.parcel){ | |
parcel = urlObject.query.parcel; | |
} | |
//If the parcel url parameter exists create search widget | |
//and search for parcel using the provided id | |
if(parcel){ | |
var parcelSearch = new Search({ | |
map: map | |
}); | |
//Specify the feature layer and the attribute field to search | |
var source = { | |
exactMatch: true, | |
outFields: ["LOWPARCELID","SITEADDRESS","OWNERNME1"], | |
featureLayer: layer, | |
infoTemplate: template, | |
searchFields: ["LOWPARCELID"] | |
}; | |
parcelSearch.set("sources", [source]); | |
parcelSearch.on("load", function(){ | |
parcelSearch.search(parcel); | |
}); | |
parcelSearch.startup(); | |
} | |
}); | |
<\/script> | |
</head> | |
<body> | |
<div id="map"></div> | |
</body> | |
</html> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment