Cool thanks! That gets me started on what I want to do.
Hi Daniel,
Here is an example on how to do this:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Sample Map</title> <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"> <style> html, body, #mapDiv { padding:0; margin:0; height:100%; } </style> <script src="http://js.arcgis.com/3.8/"></script> <script> var map, tb, polygon; require([ "esri/map", "esri/layers/FeatureLayer", "esri/graphic", "esri/tasks/GeometryService", "esri/tasks/BufferParameters", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "dojo/dom", "dojo/on", "dojo/_base/array", "dojo/domReady!" ], function( Map, FeatureLayer, Graphic, GeometryService, BufferParameters, SimpleFillSymbol, SimpleLineSymbol, Color, dom, on, array ) { map = new Map("mapDiv", { basemap: "streets", center: [-81.792107, 26.150807], zoom: 8 }); gsvc = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); var featureLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2", { mode: FeatureLayer.MODE_ONDEMAND }) map.addLayers([featureLayer]); var highlightSymbol = new SimpleFillSymbol( SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([125, 125, 125, 0.35]) ); featureLayer.on("click", function (evt) { var geom = evt.graphic.geometry; map.graphics.clear(); var highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol); map.graphics.add(highlightGraphic); var params = new BufferParameters(); params.geometries = [geom]; //buffer in linear units such as meters, km, miles etc. params.distances = [5000]; params.unit = GeometryService.UNIT_FOOT; params.outSpatialReference = map.spatialReference; gsvc.buffer(params, showBuffer); }) function showBuffer(geometries) { var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,255,0.65]), 2 ), new Color([0,0,255,0.35]) ); array.forEach(geometries, function(geometry) { var graphic = new Graphic(geometry,symbol); map.graphics.add(graphic); map.setExtent(map.graphics.graphics[0]._extent, true); }); } }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
Hi Chris. This post is 2 years old but I was wondering if you ever figured it out. This is exactly what I'm wanting to do too.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.