|
POST
|
I will put together a sample application and will attach it as a .zip so both of you can see how it was done.
... View more
10-07-2013
07:02 AM
|
0
|
0
|
1684
|
|
POST
|
Still looking for some input. Here is the code block I am working with right now. The first post contains the entire application.
// *****************************************************************************
// * EDIT FEATURES - MOVE, EDIT VERTICES, SCALE, ROTATE, OPTIONS *
// *****************************************************************************
function createEditToolbar() {
var activeFeatureLayer = null;
var landuseLayerFL = map.getLayer("landuseLayer");
var militaryareasFL = map.getLayer("militaryareas");
editModifyFeaturesTools = new esri.toolbars.Edit(map);
// ACTIVATE TOOLBAR WHEN CLICKING ON PLANTING SITES
dojo.connect(landuseLayerFL, "onClick", function(evt) {
dojo.stopEvent(evt);
activateEditToolbar(evt.graphic);
activeFeatureLayer = landuseLayerFL;
});
// ACTIVATE TOOLBAR WHEN CLICKING ON PUBLIC TREE INVENTORY
dojo.connect(militaryareasFL, "onClick", function(evt) {
dojo.stopEvent(evt);
activateEditToolbar(evt.graphic);
activeFeatureLayer = militaryareasFL;
});
// DEACTIVATE TOOLBAR
dojo.connect(map,"onClick", function(evt){
editModifyFeaturesTools.deactivate();
});
// POST EDITS AFTER TOOL IS DEACTIVATED
dojo.connect(editModifyFeaturesTools, "onDeactivate", function(editTool,graphic) {
activeFeatureLayer.applyEdits(null, [graphic], null);
alert("Feature successfully updated.");
});
}
// ACTIVATE TOOLBAR EDITING
function activateEditToolbar(graphic) {
var editTool = 0;
if (dijit.byId("tool_move").checked) {
editTool = editTool | esri.toolbars.Edit.MOVE;
}
if (dijit.byId("tool_vertices").checked) {
editTool = editTool | esri.toolbars.Edit.EDIT_VERTICES;
}
if (dijit.byId("tool_scale").checked) {
editTool = editTool | esri.toolbars.Edit.SCALE;
}
if (dijit.byId("tool_rotate").checked) {
editTool = editTool | esri.toolbars.Edit.ROTATE;
}
// SPECIFY TOOLBAR OPTIONS
var options = {
allowAddVertices: dijit.byId("vtx_ca").checked,
allowDeleteVertices: dijit.byId("vtx_cd").checked,
uniformScaling: dijit.byId("uniform_scaling").checked
};
editModifyFeaturesTools.activate(editTool, graphic, options);
}
// *****************************************************************************
// * DELETE FEATURES *
// *****************************************************************************
function editingDeleteFeature(results) {
var layers = dojo.map(results, function (result) {
return result.layer;
});
// DELETE FEATURE USING ONCLICK
dojo.forEach(layers, function (deleteFeatureslLayer) {
dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
dojo.stopEvent(evt);
// DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
if (dijit.byId("tool_delete").checked) {
deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
operation = new esri.dijit.editing.Delete({
featureLayer: deleteFeatureslLayer,
deletedGraphics: [evt.graphic]
});
// ALERT WHEN FEATURE IS DELETED
alert("Feature deleted.")
});
}
});
});
}
... View more
10-04-2013
10:48 AM
|
0
|
0
|
455
|
|
POST
|
Hi GIS folks, I started building web application using ARCGIS Javascript and slowly started adding new functionality into my web application. As my coding is getting bigger and bigger into my application, it is getting to stage where it is very difficult to look at my code. Can anyone please some provide methods / techniques through which we can organize our code in a modular way, so that allows easy debugging. I do know that we organize our code in a separate Javascript file for each functionality / feature added on to my application, but, just wanted to know, is there a right way of doing / organizing code better. And, also if you can point me to the right direction with some sample application, will be really appreciated. Thanks in advance. Regards Ganesh Ganesh, The same thing happened to me with my applications. The index.html simply got too big and had too much code. During the past couple of weeks, I started to create a modular based application. What I have done in the index.html is create references that points to javascript files on the within the application on server. Below is a screenshot on what I have done. Is this what you are looking for in terms creating a modular based application? Here is a sample of the references within the index.html page: <script type="text/javascript" src="js/editing/EditorCutFeatures.js"></script> <script type="text/javascript" src="js/editing/EditorDeleteFeatures.js"></script> <script type="text/javascript" src="js/editing/EditorModifyFeatures.js"></script> <script type="text/javascript" src="js/editing/EditorTemplatePicker.js"></script> <script type="text/javascript" src="js/find/FindNeighborhood.js"></script> <script type="text/javascript" src="js/find/FindEngineeringProject.js"></script> <script type="text/javascript" src="js/geocoding/FindAddress.js"></script> <script type="text/javascript" src="js/geocoding/FindStreet.js"></script> The function init for these tools remains in the index.html. I then created a js file which contains the location of all javascript files. Within the js folder are folders that contain specific functions such as editing, find, and geocoding (see screenshot). Is this what you are looking for? Also, I have a screenshot showing the code (editing and find sample) within one of the .js files.
... View more
10-04-2013
05:36 AM
|
0
|
0
|
1684
|
|
POST
|
I have recently added two toolsets into an application. These toolsets includ: 1. Editing (includes move, edit vertices, scale, rotate and options) 2. Delete (from operational base) The problem is that the Delete Tool will not fire when all other Editing tools are not checked. When the Move tool is checked, the delete tool will work when it is checked. My intention is for these toolsets to be separate, so when the Delete tool is checked, the Edit Tools are deactivated. Right now, they seem to work together. Is there a way I can deactivate the edit tools when the delete tool is checked and deactivate the delete tool when any of the editing tools are checked. I have attached a copy of the application as a .zip file that uses ESRI data as an example. Both toolsets are included within the application. I appreciate any assistance.
... View more
10-03-2013
09:28 AM
|
0
|
2
|
843
|
|
POST
|
I think I figured out the problem. As it turns out, I had a ) missing in the code block. I can now delete from two feature layers. Here is the updated code block: // DELETE TOOL function EditingDeleteFeature(results) { var layers = dojo.map(results, function (result) { return result.layer; }); // Ctrl+click to delete features and add this delete operation to undomanager dojo.forEach(layers, function (deleteFeatureslLayer) { dojo.connect(deleteFeatureslLayer, "onClick", function (evt) { dojo.stopEvent(evt); // DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE) if (dijit.byId("tool_delete").checked) { deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () { operation = new esri.dijit.editing.Delete({ featureLayer: deleteFeatureslLayer, deletedGraphics: [evt.graphic] }); }); } }); }); } zj_zou, Thanks for your assistance.
... View more
10-01-2013
08:25 PM
|
0
|
0
|
1159
|
|
POST
|
Try to change: // DELETE TOOL
function EditingDeleteFeature(results) {
var deleteFeatureslLayer = results[0].layer;
var layers = dojo.map(results, function (result) {
return result.layer;
});
// Ctrl+click to delete features and add this delete operation to undomanager
dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
dojo.stopEvent(evt);
// DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
if (dijit.byId("tool_delete").checked) {
deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
operation = new esri.dijit.editing.Delete({
featureLayer: deleteFeatureslLayer,
deletedGraphics: [evt.graphic]
});
});
}
});
} To: // DELETE TOOL
function EditingDeleteFeature(results) {
var layers = dojo.map(results, function (result) {
return result.layer;
});
// Ctrl+click to delete features and add this delete operation to undomanager
dojo.forEach(layers, function (deleteFeatureslLayer) {
dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
dojo.stopEvent(evt);
// DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
if (dijit.byId("tool_delete").checked) {
deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
operation = new esri.dijit.editing.Delete({
featureLayer: deleteFeatureslLayer,
deletedGraphics: [evt.graphic]
});
});
}
});
}; } Tried to incorporate your code changes, but I found that the following lines break the application (see bold code):
// DELETE TOOL
function EditingDeleteFeature(results) {
var layers = dojo.map(results, function (result) {
return result.layer;
});
// Ctrl+click to delete features and add this delete operation to undomanager
dojo.forEach(layers, function (deleteFeatureslLayer) {
dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
dojo.stopEvent(evt);
// DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
if (dijit.byId("tool_delete").checked) {
deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
operation = new esri.dijit.editing.Delete({
featureLayer: deleteFeatureslLayer,
deletedGraphics: [evt.graphic]
});
});
}
});
}; Here is an updated code block. I have commented out the dojo.forEach line. and the replaced the }; with a regular }. The functionality is still broken. Here is the code I am working with:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--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>UndoManager</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow:hidden;
}
.instructions{
padding-top:20px;
font-size:12px;
}
.undoButtons{
width:60%;
margin-left:auto;
margin-right:auto;
padding-top:4px;
}
#map{
padding:0px;
border:solid 2px #1A84AD;
-moz-border-radius: 4px;
border-radius: 4px;
}
#rightPane{
border:none;
width:300px;
}
.templatePicker {
border:solid 2px #1A84AD !important;
}
.undoIcon { background-image:url(images/undo.png); width:16px; height:16px; }
.redoIcon { background-image:url(images/redo.png); width:16px; height:16px;}
</style>
<script>var dojoConfig = { parseOnLoad:true };</script>
<script src="http://js.arcgis.com/3.7/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.dijit.editing.TemplatePicker-all");
dojo.require("esri.dijit.AttributeInspector-all");
dojo.require("esri.dijit.editing.editOperation");
var map;
function init() {
//This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
//replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
//for details on setting up a proxy page.
esri.config.defaults.io.proxyUrl = "/proxy";
esri.config.defaults.io.alwaysUseProxy = false;
map = new esri.Map("map", {
basemap: "topo",
center: [-97.367, 37.691],
zoom: 14
});
dojo.connect(map, "onLayersAddResult", initEditing);
var landuseLayer = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/FeatureServer/6", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
});
var militaryareas = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/FeatureServer/9", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
});
map.addLayers([landuseLayer, militaryareas]);
}
function initEditing(results) {
var layers = dojo.map(results, function (result) {
return result.layer;
});
// Ctrl+click to delete features and add this delete operation to undomanager
//dojo.forEach(layers, function (deleteFeatureslLayer) {
dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
dojo.stopEvent(evt);
// DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
if (dijit.byId("tool_delete").checked) {
deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
operation = new esri.dijit.editing.Delete({
featureLayer: deleteFeatureslLayer,
deletedGraphics: [evt.graphic]
});
});
}
});
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="gutters:true, design:'sidebar'" style="width:100%;height:100%;">
<div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"></div>
<div id="rightPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'">
<div id="templatePickerDiv"></div>
<div class="undoButtons">
<button id="undo" data-dojo-type="dijit.form.Button" data-dojo-props="disabled:true, iconClass:'undoIcon'" >Undo</button>
<button id="redo" data-dojo-type="dijit.form.Button" data-dojo-props="disabled:true, iconClass:'redoIcon'" >Redo</button>
<div id="tool_delete" data-dojo-type="dijit.form.ToggleButton" data-dojo-props="checked:false, iconClass:'dijitCheckBoxIcon'">Delete</div>
</div>
<div class='instructions'>
<ul style="list-style:none;padding-left:4px;">
<li><b>Create Features:</b> Select template then click on map.</li>
<li><b>Delete Features:</b> Ctrl or Cmd + Click feature.</li>
</ul>
The undo/redo buttons will become enabled after editing the feature attributes or geometry.
</div>
</div>
</div>
</body>
</html>
... View more
10-01-2013
06:24 PM
|
0
|
0
|
1159
|
|
POST
|
I have a simple application set up where the user must use a button to activate delete features. If the button is checked, the user can left click on the feature and delete. If the button is unchecked, the user cannot delete features using the left mouse click. The problem is, that I have multiple feature layers within the application and I want to be able to delete features from each feature layer. Currently, I can only delete from one feature layer. How can I delete features from each feature layer using the same button? Here is my current application code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10"> <!--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>Delete Feature</title> <link rel="stylesheet" href="http://localhost/arcgis_js_api/library/3.5/jsapi/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://localhost/arcgis_js_api/library/3.5/jsapi/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; overflow:hidden; } #map{ padding:0px; border:solid 2px #1A84AD; -moz-border-radius: 4px; border-radius: 4px; } #rightPane{ border:none; width:300px; </style> <script>var dojoConfig = { parseOnLoad:true };</script> <script src="http://localhost/arcgis_js_api/library/3.5/jsapi/init.js"></script> <script> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("dijit.Menu"); dojo.require("dijit.form.Button"); dojo.require("esri.dijit.editing.TemplatePicker-all"); dojo.require("esri.dijit.editing.editOperation"); //VARIABLES var map; //var undoManager; // FUNCTION INITIALIZE function init() { //specify the number of undo operations allowed using the maxOperations parameter //undoManager = new esri.UndoManager({ maxOperations: 10 }); // PROXY PAGE CONFIGURATION esri.config.defaults.io.proxyUrl = "http://localhost/Proxy/proxy.ashx"; // MAP EXTENT DEFINITION var initialExtent = new esri.geometry.Extent({xmin: 2089355.926669004,ymin: 212687.42173663445,xmax: 2198005.6105589992,ymax: 303894.02712456253,"spatialReference": {"wkid": 2267} }); // MAP map = new esri.Map("map", { extent: initialExtent }); //CONNECT MAP WITH DELETE FEATURE EDITING FUNCTIONALITY dojo.connect(map, "onLayersAddResult", EditingDeleteFeature); // FEATURE LAYERS FOR EDITING var publictreeinventory = new esri.layers.FeatureLayer("http://localhost/arcgis/rest/services/UrbanForestry/PublicTreeInventorySDE02/FeatureServer/0",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ['*'] }); var emergencymanagement = new esri.layers.FeatureLayer("http://localhost/arcgis/rest/services/EmergencyManagement/EmergencyManagementSDE02/FeatureServer/0",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ['*'] }); var plantingsites = new esri.layers.FeatureLayer("http://localhost/arcgis/rest/services/UrbanForestry/PublicTreeInventorySDE02/FeatureServer/1",{ //id: plantingsitesID, mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ['*'] }); map.addLayers([publictreeinventory, emergencymanagement, plantingsites]); } // DELETE TOOL function EditingDeleteFeature(results) { var deleteFeatureslLayer = results[0].layer; var layers = dojo.map(results, function(result) { return result.layer; }); // Ctrl+click to delete features and add this delete operation to undomanager dojo.connect(deleteFeatureslLayer, "onClick", function(evt) { dojo.stopEvent(evt); // DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE) if (dijit.byId("tool_delete").checked) { deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function() { operation = new esri.dijit.editing.Delete({ featureLayer: deleteFeatureslLayer, deletedGraphics: [evt.graphic] }); }); } }); } dojo.ready(init); </script> </head> <body class="claro"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="gutters:true, design:'sidebar'" style="width:100%;height:100%;"> <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"></div> <div id="rightPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'"> <div id="tool_delete" data-dojo-type="dijit.form.ToggleButton" data-dojo-props="checked:false, iconClass:'dijitCheckBoxIcon'">Delete</div> <div class='instructions'> <ul style="list-style:none;padding-left:4px;"> <li><b>To delete feature:</b> <br> Click on the Delete button to check and activate delete features. Left mouse click on feature to delete. Uncheck Delete button when finished.</li> </ul> </div> </div> </div> </body> </html>
... View more
10-01-2013
12:49 PM
|
0
|
3
|
4055
|
|
POST
|
Thanks for the responses. I had actually figured it out, but couldn't delete the thread in time. The thing that worked for me was: title="Zoom In" within the DIV and that was it. When hovering over the icon, a tooltip shows up.
... View more
09-25-2013
11:08 AM
|
0
|
0
|
1066
|
|
POST
|
I have a navigation toolbar set up that contains icons over buttons. Is there a simple way to incorporate tooltips on when I do a mouse hover over the button? Any feedback would greatly be appreciated. Here is what my toolbar looks like: [ATTACH=CONFIG]27754[/ATTACH]
... View more
09-25-2013
10:07 AM
|
0
|
4
|
1300
|
|
POST
|
Define a variable which is a reference to the map.onClick event handler. Define the event handler when the button is clicked, and detach the event handler when the identify operation is complete. So the user has to click the popup button every time to start an identify operation. var evtOnMapClick;
function btnPopup_onClick() {
evtOnMapClick = map.on("click", onMapClick);
}
function onMapClick(e) {
// identify the features and display the popup
// at the end
if (evtOnMapClick) {
evtOnMapClick.remove();
evtOnMapClick = null;
}
}
Hope it helps. Thanks. That looks promising. How would I incorporate this code block into this sample? <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--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>
San Francisco
</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .esriScalebar{
padding: 20px 20px; } #map{ padding:0;}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.dijit.Popup");
var map;
function init() {
esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
//define custom popup options
var popupOptions = {
markerSymbol: new esri.symbol.SimpleMarkerSymbol("circle", 32, null, new dojo.Color([0, 0, 0, 0.25])),
marginLeft: "20",
marginTop: "20"
};
//create a popup to replace the map's info window
var popup = new esri.dijit.Popup(popupOptions, dojo.create("div"));
map = new esri.Map("map", {
basemap: "topo",
center: [-122.448, 37.788],
zoom: 17,
infoWindow: popup
});
//define a popup template
var popupTemplate = new esri.dijit.PopupTemplate({
title: "{address}",
fieldInfos: [
{fieldName: "req_type", visible: true, label:"Type"},
{fieldName: "req_date", visible:true, label:"Date" ,format:{dateFormat:'shortDateShortTime'}}
],
showAttachments:true
});
//create a feature layer based on the feature collection
var featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0", {
mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
infoTemplate: popupTemplate,
outFields: ["req_date", "address"]
});
featureLayer.setDefinitionExpression("address != ''");
map.addLayer(featureLayer);
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<button id="identify" data-dojo-type="dijit.form.Button">Identify</button>
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'"
style="width: 100%; height: 100%; margin: 0;">
<div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"
style="border:1px solid #000;padding:0;">
</div>
</div>
</body>
</html>
... View more
09-20-2013
06:58 PM
|
0
|
0
|
625
|
|
POST
|
I have a popup identify working well within the application. What I am wanting to do is create a button that initiates the popup identify instead of simply left clicking on the feature and the popup comes up. Here is my planned workflow: 1. Click on a popup button from the main toolbar (to initiate tool) 2. Click on the feature to identify attributes. 3. Click on the popup button again if I want to identify another feature. I am wanting to do this so I am not always left clicking and a popup comes up. Also, the click is competing with other tools within the application. Has anyone been able to get this to work? Any suggestions will be greatly appreciated.
... View more
09-20-2013
12:02 PM
|
0
|
3
|
1124
|
|
POST
|
Here is an attached screenshot of my working toolset. I would like to some how use the selection options drop down list to select the selection mode. As shown in the screenshot, the user will have a variety of selection options.
... View more
09-05-2013
07:03 AM
|
0
|
0
|
570
|
|
POST
|
I have been working on a selection toolset. So far, I can select a feature layer using a variety of draw tools. What I am wanting to do is toggle between the NEW, ADD, and SUBSTRACT selection mode. Right now, the tool set is built to select NEW features as shown in the application below. I am looking for some suggestions on how I can achieve this functionality. What would be the best approach? I appreciate any assistance or feedback. Thanks. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--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>Layer in a map service - [ON-DEMAND]</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css" />
<script>var dojoConfig = { parseOnLoad:true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
<script>
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
var map, selectionToolbar, featureLayer;
// FUNCTION INITIALIZE
function init() {
map = new esri.Map("map", {
basemap: "streets",
center: [-97.395, 37.537],
zoom: 11
});
// CONNECT MAP WITH SELECTION TOOLBAR
dojo.connect(map, "onLoad", initSelectToolbar);
// FEATURE LAYER SELECTION COLOR
var FeatureLayerSelectionSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,255,197,0.75]));
FeatureLayerSelectionSymbol.setOutline(new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([0,230,169]), 2));
// FEATURE LAYER DEFINITION
featureLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/1",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
// FEATURE LAYER SET SELECTION SYMBOL
featureLayer.setSelectionSymbol(FeatureLayerSelectionSymbol);
// ADD FEATURE LAYER TO MAP
map.addLayer(featureLayer);
}
// SELECTION TOOLBAR
function initSelectToolbar(map) {
selectionToolbar = new esri.toolbars.Draw(map);
var selectQuery = new esri.tasks.Query();
dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
//hook up the button click events
dojo.connect(dojo.byId("drawPoint"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.POINT);
});
dojo.connect(dojo.byId("drawPolyline"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.POLYLINE);
});
dojo.connect(dojo.byId("drawFreehandPolyline"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYLINE);
});
dojo.connect(dojo.byId("drawPolygon"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.POLYGON);
});
dojo.connect(dojo.byId("drawFreehandPolygon"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);
});
dojo.connect(dojo.byId("drawLine"),"click", function(){
selectionToolbar.activate(esri.toolbars.Draw.LINE);
});
selectionToolbar.deactivate();
selectQuery.geometry = geometry;
var newSelection = featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
//var addSelection = featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_ADD);
//var removeSelection = featureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_SUBTRACT);
});
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<button data-dojo-type="dijit.form.DropDownButton" id="selectionoptions" data-dojo-props="value:'options'">
<span>Selection Options</span>
<div data-dojo-type="dijit.Menu" id="selectionoptionsMenu">
<div id="newSelection" data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="checked:'true'">New Selection</div>
<div id="addSelection" data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="checked:'true'">Add Selection</div>
<div id="substractSelection" data-dojo-type="dijit.CheckedMenuItem" data-dojo-props="checked:'true'">Subtract Selection</div>
</div>
</button>
<button data-dojo-type="dijit.form.Button" id="drawrectangle" onClick="selectionToolbar.activate(esri.toolbars.Draw.EXTENT);">Select By Rectangle</button>
<button data-dojo-type="dijit.form.Button" id="drawPoint">Select By Point</button>
<button data-dojo-type="dijit.form.Button" id="drawPolyline">Select By Polyline</button>
<button data-dojo-type="dijit.form.Button" id="drawFreehandPolyline">Select By Freehand Polyline</button>
<button data-dojo-type="dijit.form.Button" id="drawPolygon">Select By Polygon</button>
<button data-dojo-type="dijit.form.Button" id="drawFreehandPolygon">Select By Freehand Polygon</button>
<button data-dojo-type="dijit.form.Button" id="drawLine">Select By Line</button>
<button data-dojo-type="dijit.form.Button" onClick="featureLayer.clearSelection();">Clear Selection</button><br>
<div id="map" style="position: relative; width:1000px; height:800px; border:1px solid #000;"></div>
<span id="messages"></span>
</body>
</html>
... View more
09-05-2013
06:42 AM
|
0
|
2
|
1354
|
|
POST
|
I am looking at an ESRI sample and I like the functionality of the template picker. However, the sample I posted below allows the user to keep adding features to the map as long as the feature from the template picker is selected. My preference is to click on the feature from the template picker, add it to the map, then disable the edit mode (add feature to the map). I prefer having to click on the feature from the template picker each time I need to add a feature to the map, that way I am not in constant editing mode. I thought maybe using something like .deactivate(); or .destroy() would work? Code is posted below. Any assistance is greatly appreciated. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--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>Editable Points of Interest and Evacuation Map for Sheep Fire</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow:hidden;
background:#fff;
}
#map{
border: solid 1px #232416;
padding:0;
}
#leftPane{
width:200px;
border:none;
}
</style>
<script>var dojoConfig = { parseOnLoad:true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"></script>
<script>
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");
dojo.require("esri.map");
dojo.require("esri.dijit.editing.Editor-all");
var map;
function init() {
//This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
//replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
//for details on setting up a proxy page.
//esri.config.defaults.io.proxyUrl = "/proxy";
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
map = new esri.Map("map", {
basemap: "topo",
center: [-117.735, 34.356],
zoom: 13,
slider: false
});
dojo.connect(map, "onLayersAddResult", initiateEditor);
var pointsOfInterest = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0",{
mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well
outFields: ['*']
});
map.addLayers([pointsOfInterest]);
}
// EDITOR - ADD FEATURE
function initiateEditor(results) {
var templateLayers = dojo.map(results,function(result){
return result.layer;
});
var editingAddFeature = new esri.dijit.editing.TemplatePicker({
featureLayers: templateLayers,
rows: 'auto',
columns: 'auto',
style:'height:85%;width:98%;'
},'templatePickerDiv');
editingAddFeature.startup();
var settings = {
templatePicker: editingAddFeature,
map: map,
}
var params = {settings: settings};
var myEditor = new esri.dijit.editing.Editor(params);
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="gutters:true, design:'sidebar'" style="width:100%;height:100%;">
<div data-dojo-type="dijit.layout.ContentPane" id="header" data-dojo-props="region:'top'">Fire Map</div>
<div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"></div>
<div id="leftPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'">
<div id="templatePickerDiv"></div>
</div>
</div>
</body>
</html>
... View more
09-03-2013
09:04 PM
|
0
|
1
|
1222
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-01-2022 05:53 AM | |
| 1 | 09-18-2018 06:17 AM | |
| 1 | 06-19-2018 10:31 AM | |
| 1 | 05-15-2018 10:42 AM | |
| 1 | 10-14-2015 03:59 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-10-2025
07:13 AM
|