|
POST
|
I was thinking about this some more, and I'm not at a workstation where I can test it, but I wonder if setting the feature layer mode to esri.layers.FeatureLayer.MODE_SELECTION might work. var layer = new esri.layers.FeatureLayer(url, {
mode: esri.layers.FeatureLayer.MODE_SELECTION,
outFields: ['*']
}); I've never used the editor with a MODE_SELECTION layer, but I think it might be simple solution for your problem. Don't hide the layer.
... View more
08-23-2013
04:23 PM
|
0
|
0
|
690
|
|
POST
|
The layer must be visible to edit, kind of... You can still create objects with a template picker, and if you have an attribute inspector the attributes can be edited initially. But any editing of geometry or selecting in the map requires the layer be visible. Events that trigger editing linked to events on the graphics. I can conceptualize some ways to possibly overcome editing with the layer hidden. It is possible to query, select, update, etc with the layer hidden. But it's a lot more complicated than than just having the layer visible, particularly editing geometry or interacting with the map. I've edited attributes by identifying via map service and then making a manual call to the REST Apply Edits of the corresponding feature service to update attributes without a feature layer loaded. You can set visible to false when creating a feature layer just like a dynamic layer instead of calling hide after adding the layer. var layer = new esri.layers.FeatureLayer(url, {
mode: 1,
outFields: ['*'],
visible: false
});
... View more
08-23-2013
01:22 PM
|
0
|
0
|
690
|
|
POST
|
Here's a fiddle. Looks better in full screen. This example has a toolbar as the top region of a border container showing both declarative and programmatic methods for adding buttons, etc.
... View more
08-23-2013
11:29 AM
|
0
|
0
|
2150
|
|
POST
|
Not being able to snap, at least endpoints and vertices, limits the usefulness of these tools. For example, drawing a freehand ployline with endpoints at two points requires the user to "get close", and then edit geometry. Even better would be edge snapping, as to mimic trace in ArcMap. Whatever the reason, it would be a great upgrade in functionality.
... View more
08-23-2013
09:52 AM
|
0
|
0
|
893
|
|
POST
|
Jeff, Are you saying click events fire when panning and double clicking in your fiddle? I only get a click count on single clicks in FF and Chrome.
... View more
08-22-2013
01:04 PM
|
0
|
0
|
4154
|
|
POST
|
Got it. Draw toolbar returns a different object for on than it does with connect. PS: the draw toolbar api ref is missing events sections.
... View more
08-22-2013
11:18 AM
|
0
|
0
|
452
|
|
POST
|
I'm having issues migrating to on style events for draw toolbar. This does not register an event: var on = app.map.drawToolbar.on('draw-end', function(evt) { on.remove(); //do stuff blah blah blah }); It works on the sample. I've had no problems with on style events with dojo and other esri objects. This works: var on = layer.on('load', function() { on.remove(); //do stuff blah blah blah });
... View more
08-22-2013
11:04 AM
|
0
|
1
|
2266
|
|
POST
|
Are you looking for a toolbar that you can add your own buttons and such to? If so, dijit/Toolbar is what you are looking for. http://dojotoolkit.org/reference-guide/1.9/dijit/Toolbar.html#dijit-toolbar Attached are a couple images from an application with tabbed toolbars. All the buttons and such are added programmatically when the application loads. A single toolbar works great as the top region of a BorderContainer. [ATTACH=CONFIG]26868[/ATTACH][ATTACH=CONFIG]26869[/ATTACH] If this what you are looking for and need code snippets I can post.
... View more
08-21-2013
03:06 PM
|
0
|
0
|
2150
|
|
POST
|
I assume the geometry you are sending to geometry service is in web mercator. Web mercator does not preserve areas very well. It is after all a projection of the entire planet. Large area projections either preserve shape, area or some mix thereof depending on the area of interest. There are 2 fixes to your problem: 1) Re-project the geometry into a local spatial reference like state plane and then send that geometry to the geometry service. 2) Use the geodesic utilities of the esri.geometry namespace https://developers.arcgis.com/en/javascript/jsapi/namespace_geometry-amd.html. This is what the api measure widget uses for mercator and geographic inputs. Here's an example where geom is a polyline in web mercator. var length = esri.geometry.geodesicLengths([esri.geometry.webMercatorToGeographic(geom)], esri.Units.FEET); results.set('content', '<b>Length</b><br />' + (Math.round(length[0] * 100) / 100) + ' feet<br />' + (Math.round((length[0] / 5280) * 100) / 100) + ' miles')
... View more
08-14-2013
03:01 PM
|
0
|
0
|
1689
|
|
POST
|
Points only have move. To rotate point symbols and text you have to use the symbol's angle property. The angles can be confusing to users as you mentioned. I've used a slider in a tooltip dialog, but I'm thinking about going towards menu options "Rotate 90° Clockwise", "Rotate 90° Counterclockwise", and "Rotate 180°".
... View more
08-06-2013
07:50 AM
|
0
|
0
|
2105
|
|
POST
|
if you set a breakpoint at that line, are there any differences in the 'geom' object you are passing to map.centerAndZoom() when you switch services? John - that caught my eye too. Ryan - map.centerAndZoom takes a point as the first argument. https://developers.arcgis.com/en/javascript/jsapi/map.html#centerandzoom I noticed you were switching through geometry.type. If the geometry isn't a point centerAndZoom will not work. if (graphic.geometry.type === 'point') {
map.centerAndZoom(graphic.geometry, 18);
} else {
map.setExtent(graphic.geometry.getExtent(), true);
}
... View more
08-01-2013
11:55 AM
|
0
|
0
|
625
|
|
POST
|
Do I have to setup a custom arcgis server in production to be able to render map and save data? Do I have to use geodatabase to store the information? You can create maps without access to arcgis server. Any database will work. You can certainly use a geodatabase with a published feature service to save data.
... View more
08-01-2013
06:53 AM
|
0
|
0
|
3518
|
|
POST
|
Also, before I stripped down my code, I had an error handler for the basemap and it would return "Code undefined : Unexpected call to method or property access." but no file or line #. Not sure why this is, but sometimes I get errors in Firebug that don't have additional info or the stack. Generally when this happens I can use Developer Tools in Chrome to get more info.
... View more
07-31-2013
04:16 PM
|
0
|
0
|
1707
|
|
POST
|
Welcome to the forum Bill. Saving map info and graphics is one of the more complex concepts in web mapping with the jsapi. It takes some serious planning, coding and testing to get it working reliably. Here's a simple overview. There's a few ways to save map parameters like extent, and graphics. The key is json. Many of the esri classes have a toJson method which creates a json object, which is easily saved as plain text, and which can be used to easily recreate esri class objects. Take graphics for example: Here's a snippet from a function that prepares map annotation (graphics) for saving. var time = new Date().getTime().toString();
//javascript object with params for the save itself
// and arrays for the various geometry types
var saveObj = {
name: name,
description: description,
time: time,
userId: userId,
department, department,
project: project,
polygons: [],
polylines: [],
points: [],
markers: [],
text: []
};
//create json of each polygon object and push it to the polygon array
dojo.forEach(app.map.getLayer('gl_anno_polygon').graphics, function (g) {
var obj = g.toJson();
saveObj.polygons.push(obj)
});
//do the same polylines, points, etc
//convert js object to json
var save = dojo.toJson(saveObj);
//use ajax and some form of RDBMS to save json object
//parameters like name, userId, etc are also saved in separate fields in the database entry Here's the json of 1 polygon. {
"geometry": {
"rings": [[[-13715131.833534349, 5759372.32022381], [-13714845.194678271, 5759200.336910164], [-13715299.039533727, 5758751.269368976], [-13715514.018675784, 5759042.685539322], [-13715131.833534349, 5759372.32022381]]],
"spatialReference": {
"wkid": 102100
}
},
"attributes": {
"id": "1375306164892"
},
"symbol": {
"color": [0, 115, 197, 51],
"outline": {
"color": [0, 115, 197, 255],
"width": 1.5,
"type": "esriSLS",
"style": "esriSLSSolid"
},
"type": "esriSFS",
"style": "esriSFSSolid"
},
"infoTemplate": {
"title": "Polygon",
"content": "<div style=\"line-height:1.5;\"><a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.editStyle(${id}, 'polygon')\">Edit Polygon Style</a><br /><a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.bringTop(${id}, 'polygon')\">Bring to Top</a><br /><a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.sendBottom(${id}, 'polygon')\">Send to Bottom</a><br /><a style=\"cursor:pointer;text-decoration:none;\" onclick=\"app.anno.deleteGraphic(${id}, 'polygon')\">Delete</a></div>"
}
} On the flip side bring graphics back in by using ajax to retrieve saves by a specific user/department and display them in a data grid for the user to load a specific save. Here's a snippet that adds polygons back to the map. dojo.forEach(loadObj.polygons, function (polygon) {
//the polygon param is the json for a single polygon
// simply creating a graphic with the json recreates it attributes, symbol and info template
var graphic = new esri.Graphic(polygon);
//array of all loaded graphics for zooming
features.push(graphic);
//graphic id to identify polygon to edit, delete, etc
graphic.graphic_id = polygon.attributes.id;
//set custom objects of the graphic used by custom print task
graphic.graphic_atts = polygon.attributes;
graphic.graphic_it = polygon.infoTemplate;
//is the graphic a text symbol also for printing
graphic.graphic_text = false;
//add to the annotation polygon layer
app.map.getLayer('gl_anno_polygon').add(graphic)
});
So there's some basics. As for saving to a database. I use php and mysql. Super simple to set up and use. Php has great json functions that can be used for creating a json object for loading an entire applications for example. But whatever you have and are comfortable with will work fine. Go with a BLOB type and save yourself some hassle. You may also try using HTML5's local storage. I feel it's a little risky for saving graphics, but map saves, bookmarks, etc are usually ok. If it's a business environment or folks can't risk losing data go with a database.
... View more
07-31-2013
02:51 PM
|
1
|
0
|
3518
|
|
POST
|
You can use this same concept with multiple fields too. Instead of field param use the fields param like this: [HTML]fields="[NAME, URL]" formatter="link"[/HTML] function link(x) {
//x is array of values
var link = '<a href=" + x[1] + " target="_blank">' + x[0] + '</a>';
return link;
}
... View more
07-31-2013
11:34 AM
|
0
|
0
|
1316
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2013 06:56 AM | |
| 1 | 06-30-2015 09:17 AM | |
| 1 | 10-12-2013 07:14 AM | |
| 1 | 02-05-2014 11:05 AM | |
| 1 | 05-28-2015 11:41 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|