|
POST
|
Wondering if I should bring the shapefile in and then write its features to a GraphicLayer? Write them to a FeatureLayer? Then test for Geometry? Thoughts?
... View more
12-15-2014
11:37 AM
|
0
|
1
|
994
|
|
POST
|
I have an app that is allowing the user to add a shapefile to the map. I need to test for its geometry before or after adding. var allShapeFileLayers = []; function addShapefileToMap (featureCollection) { var fullExtent; var layers = []; arrayUtils.forEach(allShapeFileLayers, function(layer) { app.map.removeLayer(layer); }); arrayUtils.forEach(featureCollection.layers, function (layer) { var infoTemplateSF = new InfoTemplate("Details", "${*}"); var featureLayerSF = new FeatureLayer(layer, { infoTemplate: infoTemplateSF }); featureLayerSF.on('click', function (event) { app.map.infoWindow.setFeatures([event.graphic]); }); changeRenderer(featureLayerSF); fullExtent = fullExtent ? fullExtent.union(featureLayerSF.fullExtent) : featureLayerSF.fullExtent; layers.push(featureLayerSF); }); allShapeFileLayers = layers; app.map.addLayers(allShapeFileLayers); app.map.setExtent(fullExtent.expand(1.25), true); dom.byId('upload-status').innerHTML = ""; dojo.byId("RunQueryShapefile").style.display = "block"; // TEST FOR POLYGON ONLY if ( allShapeFileLayers.geometry.type === "point" || allShapeFileLayers.geometry.type === "multipoint") { alert("Point or multiPoint"); } else if ( allShapeFileLayers.geometry.type === "line" || allShapeFileLayers.geometry.type === "polyline") { alert("Poline or polyline"); } else { alert("Polygon"); } }
... View more
12-15-2014
11:27 AM
|
0
|
2
|
2237
|
|
POST
|
THINK I GOT IT WITH THIS params.geometries = [gr.geometry];
... View more
12-12-2014
09:20 AM
|
0
|
1
|
1814
|
|
POST
|
In responce to my last post...I am trying to buffer the newly drawn GRaphics that Are added to the GrpahicsLayer with this....think I am breaking here: geometryService22.on("buffer-complete", function(result){ I THINK I am declaring my Geometry incorrectly in the PARAMS definition....thoughts? function runAnalysis(gr){ // This is your final graphic to use in your analysis: console.log("Final Graphic: ", gr); dom.byId("ringCount").innerHTML = gr.geometry.rings.length; // Run your spatial query here... // Get Buffer Distance from the Textbox input varBufferDistance1 = registry.byId("BufferDistance"); //alert("Action2 Aa"); var params1 = new BufferParameters(); params.geometries = [drawnGL]; params1.distances = [ varBufferDistance1 ]; params1.outSpatialReference = app.map.spatialReference; params1.unit = GeometryService.UNIT_STATUTE_MILE; BufferTool22(map, params1); // Call BufferTool function and pass the Buffer Parameters } function BufferTool22(map, params1){ // geometry service that will be used to perform the buffer var geometryService22 = new GeometryService("https://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService22.buffer(params1); geometryService22.on("buffer-complete", function(result){ app.map.graphics.clear(); // draw the buffer geometry on the map as a map graphic var symbol22 = new SimpleFillSymbol( SimpleFillSymbol.STYLE_NULL, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([105,105,105]), 2 ),new Color([255,255,0,0.25]) ); bufferGeometry22 = result.geometries[0] BufferGraphic22 = new Graphic(bufferGeometry22, symbol22); app.map.graphics.add(BufferGraphic22); Bufferextent22 = BufferGraphic22.geometry.getExtent().expand(3.0); app.map.setExtent(Bufferextent22); }
... View more
12-12-2014
08:49 AM
|
0
|
2
|
1814
|
|
POST
|
One last question... Should I not be able to specify my Geometry as such in Params? I am using these params to then buffer the graphics I just created and then push that to a query. function runAnalysis(gr){ // This is your final graphic to use in your analysis: console.log("Final Graphic: ", gr); dom.byId("ringCount").innerHTML = gr.geometry.rings.length; // Get Buffer Distance from the Textbox input varBufferDistance = registry.byId("BufferDistance"); var params = new BufferParameters(); params.geometries = [drawnGL]; params.distances = [ varBufferDistance ]; params.outSpatialReference = app.map.spatialReference; params.unit = GeometryService.UNIT_STATUTE_MILE; BufferTool(map, params); // Call BufferTool function and pass the Buffer Parameters }
... View more
12-12-2014
08:14 AM
|
0
|
3
|
1814
|
|
POST
|
STEVE, ROBERT AND OWEN Thank you all for your help, examples and thoughts....VERY appreciated... Have most working now just need to feed the Geometry to my Query (which is already working on a map click)...SO should not be any problem... Cheers and thanks again.....dont know who to mark as correct answer as you all have provided fantastic input...will choose Owens just for the fact that is someone visits this the working code example is there.
... View more
12-12-2014
07:46 AM
|
1
|
5
|
1814
|
|
POST
|
PART 1: Add the graphics to my Graphic Layer Like this???? O am attempting to comment out eixting code that draws pushed the graphics to the graphics map layer and replace with code that creates a GraphicsLayer and adds the graphics to it... That seem correct: function addGraphic(evt) { //deactivate the toolbar and clear existing graphics tb.deactivate(); app.map.enableMapNavigation(); // figure out which symbol to use var symbol; if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") { symbol = DrawPicturemarkerSymbol; } else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") { symbol = DrawlineSymbol; } else { symbol = DrawfillSymbol; } // REMOVE FROM EXISTING app.map.graphics.add(new Graphic(evt.geometry, symbol)); // ADD THIS TO ADD GRAPHICS TO GraphicLayer var DrawnGraphics = new esri.layers.GraphicsLayer(); app.map.DrawnGraphics.add(evt.geometry, symbol); }
... View more
12-11-2014
12:18 PM
|
0
|
1
|
2869
|
|
POST
|
Just getting the straight....I would run the Union on the New GraphicsLayer I created instead of the map graphics I am doing currently?
... View more
12-11-2014
12:01 PM
|
0
|
9
|
2869
|
|
POST
|
I think I need to start with the thought of trying to determine how many objects there are drawn in the map. Say I have the user and they draw 4 different polygons via the code I pasted in the first post above. 1. How would I test to determine if there are more than one feature? ... if thats the case then I run a Union. if not I go right to the query 2. What do I run the Union against....its just a graphic.... 3. How to I specify the specific graphics in the Union (what if there are other graphics in the map, I dont want those to be in the union) 4. Can I assign the graphics being added via this draw tool to a specific ID or feature that I can reference in the Union and the eventual Query?
... View more
12-11-2014
09:09 AM
|
0
|
11
|
2869
|
|
POST
|
I was hoping that I can fire that query off separately.....the user might create a couple polygons....these polygons will then be used for the query. I think can work?
... View more
12-08-2014
11:02 AM
|
0
|
0
|
2869
|
|
POST
|
I have this piece of code that is taking a graphic drawn by the user and creating a shapefile. Right now it creates the .dbf .shp .shx and the user can download it. What I want is a .prj file to be created and the whole thing be zipped up.... Anyone know how to do this in JavaScript? See attached Thanks in Advance if someone can help.
... View more
12-08-2014
08:29 AM
|
0
|
3
|
2207
|
|
POST
|
I am using the below code to draw graphics in the map. Everything works great.... But I want to use those geometries to do spatial queries. I need to call a specific Feature to get the geometry for the query making the Graphic far to general. I am trying to select all the features from X Feature that are within the Geometry Drawn. Noting that there might be other graphics in the map so thats why I am thinking I need to separate them and get them into a Feature that I can reference by itself. I think I need to push the graphics drawn to a Feature? Not sure how to do this. Once I have the feature I can use its geometry for the query. Not sure if I am on the right path here...AND unsure how to convert the graphic to a feature so that its geometry can be used in a query....hope someone can help. // markerSymbol is used for point and multipoint, see http://raphaeljs.com/icons/#talkq for more examples var DrawmarkerSymbol = new SimpleMarkerSymbol(); DrawmarkerSymbol.setPath("M16,4.938c-7.732,0-14,4.701-14,10.5c0,1.981,0.741,3.833,2.016,5.414L2,25.272l5.613-1.44c2.339,1.316,5.237,2.106,8.387,2.106c7.732,0,14-4.701,14-10.5S23.732,4.938,16,4.938zM16.868,21.375h-1.969v-1.889h1.969V21.375zM16.772,18.094h-1.777l-0.176-8.083h2.113L16.772,18.094z"); DrawmarkerSymbol.setColor(new Color("#00FFFF")); // http://blogs.esri.com/esri/arcgis/2012/02/03/esri-picture-marker-symbol-generator-for-javascript-developers/ var DrawPicturemarkerSymbol = new esri.symbol.PictureMarkerSymbol({ "angle": 0, "xoffset": 0, "yoffset": 12, "type": "esriPMS", "url": "http://static.arcgis.com/images/Symbols/Basic/RedStickpin.png", "contentType": "image/png", "width": 24, "height": 24 }); // lineSymbol used for freehand polyline, polyline and line. var DrawlineSymbol = new CartographicLineSymbol( CartographicLineSymbol.STYLE_SOLID, new Color([255,0,0]), 2, CartographicLineSymbol.CAP_ROUND, CartographicLineSymbol.JOIN_MITER, 5 ); var DrawfillSymbol = new SimpleFillSymbol( "solid", new SimpleLineSymbol("solid", new Color([255,0,0]), 2), new Color([0,128,255,0.25]) ); function initToolbar() { tb = new Draw(app.map); tb.on("draw-end", addGraphic); // event delegation so a click handler is not // needed for each individual button on(dom.byId("infoShapefileCreate"), "click", function(evt) { if ( evt.target.id === "info" ) { return; } var tool = evt.target.id.toLowerCase(); app.map.disableMapNavigation(); tb.activate(tool); }); } function addGraphic(evt) { //deactivate the toolbar and clear existing graphics tb.deactivate(); app.map.enableMapNavigation(); // figure out which symbol to use var symbol; if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") { symbol = DrawPicturemarkerSymbol; } else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") { symbol = DrawlineSymbol; } else { symbol = DrawfillSymbol; } app.map.graphics.add(new Graphic(evt.geometry, symbol)); }
... View more
12-08-2014
08:24 AM
|
0
|
16
|
7015
|
|
POST
|
I tried the below: trying to removeLayer but this does not work it keeps adding to the layer arrayUtils.forEach(featureCollection.layers, function (layer) { var infoTemplateSF = new InfoTemplate("Details", "${*}"); var featureLayerSF = new FeatureLayer(layer, { infoTemplate: infoTemplateSF }); //associate the feature with the popup on click to enable highlight and zoom to featureLayerSF.on('click', function (event) { app.map.infoWindow.setFeatures([event.graphic]); }); //change default symbol if desired. Comment this out and the layer will draw with the default symbology changeRenderer(featureLayerSF); fullExtent = fullExtent ? fullExtent.union(featureLayerSF.fullExtent) : featureLayerSF.fullExtent; app.map.removeLayer(featureLayerSF) layers.push(featureLayerSF); });
... View more
12-05-2014
12:02 PM
|
0
|
0
|
1824
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|