POST
|
Hi I am trying to drag and drop TOC layers on map, layers which are coming from ArcGIS services. currently if i click on checkbox the layers will load on map but i also want if i drag and drop layers it should display on the map...can someone please help me get out of this problem.thank you.........
... View more
08-22-2016
11:29 PM
|
0
|
2
|
1154
|
POST
|
I have school layer for state.I am able to zoom to selected district from combo box.now i wanted to display total number of schools in that selected district.Can any one tell me how to do it. <!DOCTYPE html>
<html>
<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="https://js.arcgis.com/3.16/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<style>
html, body, #map {
padding:0;
margin:0;
height:100%;
}
#HomeButton {
position: absolute;
top: 95px;
left: 20px;
z-index: 50;
}
#search {
display: block;
position: absolute;
z-index: 2;
top: 20px;
left: 74px;
}
</style>
<script src="https://js.arcgis.com/3.16/"></script>
<script>
var map;
require([
"esri/map", "esri/dijit/BasemapGallery","esri/dijit/HomeButton","esri/dijit/Search",
"esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/FeatureLayer", "dojo/parser","esri/dijit/Attribution",
"dijit/form/ComboBox", "dojo/data/ItemFileReadStore", "dojo/_base/array", "dijit/registry", "esri/tasks/query",
"esri/symbols/SimpleLineSymbol","esri/Color", "esri/InfoTemplate", "esri/symbols/SimpleFillSymbol",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane",
"dojo/domReady!"
], function(
Map, BasemapGallery,HomeButton,Search,ArcGISDynamicMapServiceLayer,FeatureLayer,
parser,Attribution, ComboBox, ItemFileReadStore, array, registry,Query,SimpleLineSymbol,Color,InfoTemplate,SimpleFillSymbol
) {
parser.parse();
map = new Map("map", {
basemap: "topo",
center: [77.2, 14],
zoom: 7
});
var operationalLayer = new ArcGISDynamicMapServiceLayer("http://117.247.176.60:6080/arcgis/rest/services/BC_SH/BC_SH/MapServer");
var school = new FeatureLayer("http://117.247.176.60:6080/arcgis/rest/services/BC_SH/BC_SH/MapServer/0", {
mode: FeatureLayer.MODE_SELECTION,
outFields: ["*"]
});
map.addLayers([operationalLayer,school]);
var search = new Search({
map: map
}, "search");
search.startup();
var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
//add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps
var basemapGallery = new BasemapGallery({
showArcGISBasemaps: true,
map: map
}, "basemapGallery");
basemapGallery.on('load',function(){
basemapGallery.remove('basemap_0');
basemapGallery.remove('basemap_1'); //remove unwanted base map from base map gallery
basemapGallery.remove('basemap_2');
basemapGallery.remove('basemap_3');
basemapGallery.remove('basemap_4');
basemapGallery.remove('basemap_5');
basemapGallery.remove('basemap_8');
});
basemapGallery.startup();
basemapGallery.on("error", function(msg) {
console.log("basemap gallery error: ", msg);
});
var populateList = function(results) {
//Populate the ComboBox with unique values
var zone;
var values = [];
var testVals = {};
//Loop through the QueryTask results and populate an array
//with the unique values
var features = results.features;
array.forEach(features, function(feature) {
zone = feature.attributes.DistrictName;
if (zone) {
if (!testVals[zone]) {
testVals[zone] = true;
values.push({
name: zone
});
}
}
});
//Create a ItemFileReadStore and use it for the
//ComboBox's data source
var dataItems = {
identifier: 'name',
label: 'name',
items: values
};
var store = new ItemFileReadStore({
data: dataItems
});
registry.byId("mySelect").set('store', store);
}
queryTask = new esri.tasks.QueryTask("http://117.247.176.60:6080/arcgis/rest/services/BC_SH/BC_SH/MapServer/0");
var queryTaskTouches = new esri.tasks.QueryTask("http://117.247.176.60:6080/arcgis/rest/services/BC_SH/BC_SH/MapServer/0");
var query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["DistrictName"];
query.where = "DistrictName<> ''";
queryTask.execute(query, populateList);
app = {
zoomRow: function(id){
var symbol = new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 1);
school.clearSelection();
var query = new Query();
query.where = "DistrictName='" + id.toString() + "'";
query.outFields = ["DistrictName"];
query.outSpatialReference = { wkid: 32643 };
query.returnGeometry = true;
school.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
var extent = esri.graphicsExtent(features);
if (!extent && features.length == 1) {
var point = features[0];
extent = new esri.geometry.Extent(point.x - 1, point.y - 1, point.x + 1, point.y + 1, point.SpatialReference);
}
if (extent) {
// assumes the esri map object is stored in the globally-scoped variable 'map'
map.setExtent(extent)
}
});
}
};
});
</script>
</head>
<body class="claro">
<div id="search"></div>
<div id="map"
data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'center'"
style="padding:0;">
<div style="position:absolute; right:10px; top:10px; z-Index:999;">
<div data-dojo-type="dijit/TitlePane"
data-dojo-props="title:'Switch Basemap', closable:false, open:false">
<div data-dojo-type="dijit/layout/ContentPane" style="width:200px; height:280px; overflow:auto;">
<div id="basemapGallery"></div>
</div>
</div>
</div>
<div style="position:absolute; right:250px; top:10px; z-Index:999;" value="Select District" id="mySelect" data-dojo-type="dijit.form.ComboBox" onchange="app.zoomRow(document.getElementById('mySelect').value);"/>
<div id="HomeButton"></div>
</div>
</body>
</html>
... View more
05-01-2016
10:24 PM
|
0
|
2
|
2024
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|