POST
|
Hello, I would like some help please. I have an application which enables a user to draw a polyline on a map. Through JavaScript, on draw end this polyline is added as a graphic on a graphics layer. What I can't figure out is how can a user edit the vertices of this polyline once it has been added to the GraphicsLayer? This is my code so far: if (evt.geometry.type === "polyline") {
if (map.getScale() < MAP_SCALE) {
var symbol = new SimpleMarkerSymbol();
var fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 128]), 3));
symbol = fillSymbol;
polylineLayerGL = new GraphicsLayer();
pipeGraphic = new Graphic(evt.geometry, symbol);
polylineLayerGL.add(pipeGraphic);
map.addLayer(polylineLayerGL);
pipeCount += 1;
//custAttribInsp(evt);
} else {
return;
} To edit: function initEditor(evt) {
console.log("initEditing", evt);
// var map = this;
var currentLayer = null;
var layers = arrayUtils.map(evt.layers, function(result) {
return result.layer;
});
console.log("layers", layers);
var editToolbar = new Edit(map);
editToolbar.on("deactivate", function(evt) {
currentLayer.applyEdits(null, [evt.graphic], null);
});
arrayUtils.forEach(layers, function(layer) {
var editingEnabled = false;
layer.on("dbl-click", function(evt) {
event.stop(evt);
if (editingEnabled === false) {
editingEnabled = true;
editToolbar.activate(Edit.EDIT_VERTICES , evt.graphic);
} else {
currentLayer = this;
editToolbar.deactivate();
editingEnabled = false;
}
});
layer.on("click", function(evt) {
event.stop(evt);
if (evt.ctrlKey === true || evt.metaKey === true) { //delete feature if ctrl key is depressed
layer.applyEdits(null,null,[evt.graphic]);
currentLayer = this;
editToolbar.deactivate();
editingEnabled=false;
}
});
});
var templatePicker = new TemplatePicker({
featureLayers: layers,
rows: "auto",
columns: 2,
grouping: true,
style: "height: auto; overflow: auto;"
}, "templatePickerDiv");
templatePicker.startup();
var drawToolbar = new Draw(map);
var selectedTemplate;
templatePicker.on("selection-change", function() {
if( templatePicker.getSelected() ) {
selectedTemplate = templatePicker.getSelected();
}
switch (selectedTemplate.featureLayer.geometryType) {
case "esriGeometryPoint":
drawToolbar.activate(Draw.POINT);
break;
case "esriGeometryPolyline":
drawToolbar.activate(Draw.POLYLINE);
break;
case "esriGeometryPolygon":
drawToolbar.activate(Draw.POLYGON);
break;
}
});
drawToolbar.on("draw-end", function(evt) {
drawToolbar.deactivate();
editToolbar.deactivate();
var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes);
var newGraphic = new Graphic(evt.geometry, null, newAttributes);
selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);
});
} However, nothing is happening. Any suggestions please.@ Thanks frank
... View more
01-14-2015
12:55 AM
|
0
|
0
|
4673
|
POST
|
This is what I have done so far: parser.parse(); app.printUrl = "http://aphrodite/arcgis/rest/services/Layout/WSC_LAYOUT1/GPServer/Export%20Web%20Map"; esri.config.defaults.io.corsEnabledServers.push("local_server"); app.map = new Map("map"); //Base map var basemap = new ArcGISDynamicMapServiceLayer("http://local_server/arcgis/rest/services/NAME/Basemap/MapServer/"); basemap.setVisibleLayers([0, 1, 2, 3, 4, 5, 6, 7]); app.map.addLayer(basemap); // add graphics for feature var url = "http://local_server/arcgis/rest/services/NAME/NAME/FeatureServer/n"; var pipeFeatureLayer = new FeatureLayer(url, { "mode": FeatureLayer.MODE_SNAPSHOT }); app.map.addLayer(pipeFeatureLayer);
... View more
09-26-2014
12:24 AM
|
0
|
0
|
303
|
POST
|
Hello, I am trying to print a map using a print service. I have followed the example on the ArcGIS site namely: Print templates with esri.request | ArcGIS API for JavaScript However I can't get it to work using a local feature layer. Can someone please give some advice. Thanks Frank
... View more
09-25-2014
10:07 PM
|
0
|
1
|
3659
|
POST
|
I found the problem. What I did is I removed the toFixed(2) method and I added replaced the pipePoint with the following:
var pipePoint = new Point((coorX[0] + midPointX), (coorY[0] + midPointY), map.spatialReference);
... View more
09-23-2014
12:27 AM
|
0
|
0
|
312
|
POST
|
Dear all, I am trying to put a label(TextSymbol) at a polyline midpoint (graphics layer). This is my code so far: var startX = coorX[0]; var endX = coorX[coorX.length - 1]; var midPointX = ((endX - startX) / 2).toFixed(2); var startY = coorY[0]; var endY = coorY[coorY.length - 1]; var midPointY = ((endY - startY) / 2).toFixed(2); var font = new Font("12px", Font.STYLE_NORMAL, Font.STYLE_NULL, Font.VARIANT_NORMAL, Font.WEIGHT_NULL, "Arial"); var pipePoint = new Point(midPointX, midPointY, map.spatialReference); // create a text symbol var textSymbol = new TextSymbol("LABEL TEXT!!!", font, new Color([0, 0, 0])); var labelGraphic = new Graphic(pipePoint, textSymbol); // add the label point graphic to the map map.graphics.add(labelGraphic); Can't see the label anywhere. I tried to increase the font size but with no success. I'd appreciate some help. Thanks in advance. Frank
... View more
09-23-2014
12:11 AM
|
0
|
1
|
3721
|
POST
|
Hi Riyas, No I am referring to ArcGIS JavaScript API.
... View more
08-27-2014
10:27 PM
|
0
|
1
|
385
|
POST
|
Hello, I am quite new to ArcGIS and would like to know if it's possible to find a street name(s) after for example drawing a polyline on the same street. Thanks Frank
... View more
08-27-2014
10:04 PM
|
0
|
3
|
2458
|
POST
|
Thanks Riyas, Adjusted the streetLvlZoom but still going outwards. About the last level ID, where can I modify it or is it a server attribute?
... View more
08-04-2014
12:08 AM
|
0
|
3
|
732
|
POST
|
Hi Owen, Thanks for your help. I modified a bit the example above by including an ArcGISDynamicMapServiceLayer and instead of zooming in it is doing the opposite. Is there something else I should be including or enabling? Here is what I did:
var streetLvlZoom = 17;
require([
"esri/map", "esri/toolbars/draw",
"esri/symbols/SimpleMarkerSymbol",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/CartographicLineSymbol",
"esri/graphic",
"esri/Color",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function(
Map, Draw,
SimpleMarkerSymbol, ArcGISDynamicMapServiceLayer, SimpleLineSymbol,
SimpleFillSymbol, CartographicLineSymbol,
Graphic,
Color, dom, on
) {
map = new Map("mapDiv", {
zoom: 12
});
// Base map
var basemap = new ArcGISDynamicMapServiceLayer("http://myserver/Basemap/map/");
basemap.setVisibleLayers([0, 1, 2, 3, 4, 5, 6, 7]);
map.addLayer(basemap);
map.on("load", initToolbar);
// Zoom in to local area
map.on("click", function(e){
if (map.getLevel() < streetLvlZoom){
map.centerAndZoom(e.mapPoint, streetLvlZoom)
}
});
The rest wasn't modified. Frank
... View more
08-03-2014
11:26 PM
|
0
|
7
|
732
|
POST
|
Hello, I am new to ArcGIS JavaScript API and would like some help. I have a scenario where a user has to draw a graphic, mainly a polyline and some points on a map. To avoid confusion I want to limit the user to zoom in to street level prior to start drawing. What I am trying to achieve here is when the user clicks on the locality he/she wants to draw on, on click event the map zooms in to street layer/level. I have been looking around but can't find a way to do it. I'll appreciate any kind of help. Thanks Frank
... View more
08-03-2014
12:15 AM
|
0
|
9
|
3483
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|