{ type: 'feature', requireToken: true, url: 'http://SOME_URL/ArcGIS/rest/services/SOME_TOWN_IN_OREGON/Fire_Hydrants/MapServer/0', name: 'Fire Hydrants', id: 'fire_hydrants', outFields: ['*'], itTitle: 'Hydrant', itContentType: 'function', //'function' or 'text' itContent: '', itContentFunction: 'hydrant', visible: false, opacity: 1, legend: true, toc: true, info: false, infoHtml: '' }
dojo.forEach(config.featureLayers, function(fl) { var url; if (fl.requireToken == true) { url = fl.url + '?token=' + config.app.token } else { url = fl.url } var it = new esri.InfoTemplate(); it.setTitle(fl.itTitle); if (fl.itContentType == 'text') { it.setContent(fl.itContent); } else if (fl.itContentType == 'function') { //turns out we want some dijits in our infoWindow eval('it.setContent(viewer.itContentFunctions.' + fl.itContentFunction + ')') //set the content via a function; in this case viewer.itContentFunctions.hydrant; see below } else { it.setContent('There must not be any important info about this feature.'); } var layer = new esri.layers.FeatureLayer(url, { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: fl.outFields, infoTemplate: it, id: fl.id, visible: fl.visible, opacity: fl.opacity }); if (fl.legend == true) { viewer.legendLayers.push({ layer: layer, title: fl.name }) } var info = ''; if (fl.info == true) { info = fl.infoHtml } //toc controls viewer.map.addLayer(layer); });
var viewer = { itContentFunctions: { hydrant: function(graphic) { var x = Math.round(Math.random() * 1000000); var content = new dijit.layout.ContentPane({ style: 'padding:0;', content: '<div style="padding-bottom:6px;">Buffer this hydrant:</div><div id="hydrant_buffer_dist_' + x + '" dojoType="dijit.form.NumberSpinner" value="500" smallDelta="25" contraints="{min:100,max:1200,places:0}" style="width:80px;"></div> <div id="hydrant_buffer_button_' + x + '" dojoType="dijit.form.Button">Buffer</div>' }); dojo.connect(dijit.byId('hydrant_buffer_button_' + x), 'onClick', function() { viewer.itContentFunctions.hydrantBuffer(graphic.geometry, x); viewer.map.infoWindow.hide(); /* viewer.mapTipsShow('<img src="images/waiting_map_tips.gif" style="height:14px; width:14px;" /> Buffer in progress...');*/ }); return content.domNode; }, hydrantBuffer: function(geom, id) { viewer.map._layers.gl.clear(); var params = new esri.tasks.BufferParameters(); params.geometries = [geom]; params.distances = [eval('parseInt(dijit.byId("hydrant_buffer_dist_' + id + '").value)')]; params.unit = esri.tasks.GeometryService.UNIT_FOOT; params.outSpatialReference = viewer.map.spatialReference; viewer.geoSrv.buffer(params, function(geoms) { //viewer.mapTipsHide(); var symbol = new esri.symbol.SimpleFillSymbol('solid', new esri.symbol.SimpleLineSymbol('solid', new dojo.Color([0, 0, 255]), 2), new dojo.Color([0, 0, 255, 0.25])); dojo.forEach(geoms, function(geometry) { var graphic = new esri.Graphic(geometry, symbol, { ID: '7', __print: true, __whatAmI: 'a hydrant buffer', __addToMapSave: false, __style: { who: 'mxdSelect' }, __db: 'schema.gdb', __sdeDump: config.app.dumpUserGraphicsToSde }); viewer.map._layers.gl.add(graphic); viewer.map.setExtent(graphic.geometry.getExtent(), true); }); }); } } }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.