|
POST
|
Hi I have a internal project about to go live, I really want to have snapping for measurements and user added graphics. At the moment a simple map.enableSnapping({ snapKey: dojo.keys.copyKey }); gets it on. However snapping only appears to work against already drawn graphics, not on any of my vector layers on my map. My map is made up of four ArcGISDynamicMapServiceLayer - added like this var background = new esri.layers.ArcGISDynamicMapServiceLayer(mapservice1, { "id": "mainbasemaps" }); // map.addLayer(background); background.setDPI(150); var altmaps = new esri.layers.ArcGISDynamicMapServiceLayer(altbasemaps, { "id": "altbasemaps" }); // map.addLayer(altmaps); var aerials = new esri.layers.ArcGISDynamicMapServiceLayer(aerialservice, { "id": "aerialmaps" }); //map.addLayer(aerials); dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapservice2, { "id": "mainmap" }); dynamicMapServiceLayer.setOpacity(0.9); dynamicMapServiceLayer.setDPI(96) map.addLayers([background],[altmaps],[aerials],[dynamicMapServiceLayer]); from the API documentation Reference to a feature or graphics layer that will be a target snapping layer. The default option is to set all feature and graphics layers in the map to be target snapping layers. So I would have thought it would snap to everything? I've tried defining a specific layer like var snappinglayer = new esri.layers.FeatureLayer(mapservice2 + "/4", { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); ... var layerInfos = [{ layer: snappinglayer }]; snapManager.setLayerInfos(layerInfos); But that fails. Any ideas what I've missed? ACM
... View more
04-17-2013
06:13 AM
|
0
|
6
|
2480
|
|
POST
|
HI I have this chunk of code that sets the snapping environment to a specific sublayer in a map service
var snappinglayer = new esri.layers.FeatureLayer(mapservice1 + "/6", {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
var snapManager = map.enableSnapping({ snapKey: dojo.keys.copyKey });
snapManager.tolerance=15;
var layerInfos = [{ layer: snappinglayer }];
snapManager.setLayerInfos(layerInfos);
When the CTRL key is held down whilst drawing a new polygon, I get the default blue cross on the required layer, but the drawing doesn't snap to it at all [ATTACH=CONFIG]22690[/ATTACH] See image. If I remove the layer requirements the new drawing polygon will ONLY snap to previously drawn user graphics. But it does work exactly as it should. Prior to patching with SP1 the time taken for the blue cross to move on my required layer was painful. With SP1 it at least moves at a OK speed, but simply doesn't snap Have I missed something? Cheers ACM
... View more
03-18-2013
04:33 AM
|
0
|
0
|
1009
|
|
POST
|
Sorted it all by myself 😄 I needed to assigned IDs to the graphics as they were being read in, with the stored localstorage index, so;
for (var i = 0; i < localStorage.length; i++) {
var n= "SavedGraphic" + i
saved = dojo.fromJson(localStorage.getItem(localStorage.key(i)));
console.debug(localStorage.getItem(localStorage.key(i)))
var graphic = new esri.Graphic(saved);
graphic.setAttributes({ "ID": n,"LSNo":i });
userGraphics.add(graphic);
}
This gives each graphic that is loaded in for a new session a attribute (LSNo) that equals the index in localstorage. Then I need to delete the store when it is edited - I also need to delete the store if it is a new graphic, added that session. So in the createToolbarAndContextMenu function (I'm using the function from (http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/graphics_contextmenu.html) dojo.connect(editToolbar, "onDeactivate", function (tool, graphic, info) {
if (graphic.attributes.newID) {
localStorage.removeItem(graphic.attributes.newID)
}
else {
localStorage.removeItem(localStorage.key(graphic.attributes.LSNo))
}
var now = new Date();
var n = now.getTime();
GraphicName = "storedGraphic" + n
window.localStorage.setItem(GraphicName, dojo.toJson(graphic.toJson()));
}); Having added graphic.setAttributes({ newID: GraphicName }) To the addToMap function. So if the graphic has been added because it was saved before or if it was added in that session the delete from localstorage is treated differently. For previously saved the index is used. For newly added the id is used. Finally, to the createGraphicsMenu function, the delete section, I add userGraphics.remove(selected); if (selected.attributes.newID) {
localStorage.removeItem(selected.attributes.newID)
}
else {
localStorage.removeItem(localStorage.key(selected.attributes.LSNo))
} That does the same for deletions. I'm sure there is a tidier way, bu this appears to work.
... View more
03-15-2013
06:09 AM
|
1
|
0
|
880
|
|
POST
|
Ah found it - I knew I'd seen this thread - however I found it too late - I posted a new one http://forums.arcgis.com/threads/79938-Save-load-graphics-to-loacl-storage In it I show how I am writing and reading from local storage, but need some pointers on editing/deleting Cheers ACM
... View more
03-15-2013
04:55 AM
|
0
|
0
|
1202
|
|
POST
|
I'm sure I was subscribed to a thread about this, but can't find it, so sorry, starting a new one. I've got some code (that I've added to one of the samples here.) that uses the HTML5 local storage and then retrieving it on next login. (in total 10 lines of code, so I am quite pleased with my self, seeing this morning I had never used localstorage before) This works fine, but I am now stuck over how to make any edits made to over-write the localstorage version of that option (including deletes) - obviously as it is read in some sort of unique ID needs to be assigned then used later on the edit - in my real app I use the right click context menu editing feature. Any help appreciated. Cheers ACM
... View more
03-15-2013
02:47 AM
|
0
|
1
|
2984
|
|
POST
|
sorry please ignore - didn't notice forum I was posting in
... View more
03-15-2013
02:39 AM
|
0
|
0
|
1564
|
|
POST
|
😄 There are some benefits in being an untrained hack - I never notice if I have a horrid mixture - you should see some of the javascript/.asp pages I have done in the past - a total mix of syntax. I can remember having issues over this, but can't recall the specifics, it was a long time ag (well last year sometime)
... View more
02-27-2013
06:09 AM
|
0
|
0
|
2835
|
|
POST
|
Hi Using esri.symbol.SimpleMarkerSymbol and esri.symbol.TextSymbol to allow users to add points and text - however if the text is set to, say, 12pt, it stays at 12 pt, even when zoomed out. Is it possible to have te equivalent setting to ArcMap's "Scale Symbol" option - so it is as if the text or point are spray painted onto the ground and get smaller as you zoom out - like any other feature? Cheers ACM
... View more
02-27-2013
05:11 AM
|
0
|
0
|
836
|
|
POST
|
I've not had an issue - here's my code for a collapsed at start bottom pane
<div dojotype="dojox.layout.ExpandoPane"
splitter="true"
duration="125"
region="bottom"
title=""
startexpanded="false"
id="footer"
maxwidth="275"
style="height: 150px;">
<div id='xxx' class='ref'></div>
</div>
... View more
02-27-2013
12:17 AM
|
0
|
0
|
2835
|
|
POST
|
Yes - we use it fine - after creating a brand new Enterprise 10.1 database - that was what was holding me back. Ensure that the account you use in the MXD. Service has the required rights and that they are being passed through OK. Set AGS logging to debug and take a look at everything that may be relevant (you may see failed attempts to edit or bad logins) - if you are using MS SQL switch on all the logging tools there to see if there are any failed write attempts. Sacrifice the relevant amount of small furry animals to the dark gods. Good luck ACM
... View more
02-20-2013
11:30 PM
|
0
|
0
|
3104
|
|
POST
|
Hi - old thread revival - I'm trying to get the Id task to get values from a DTM stored as a raster/grid. The ID task brings back data, but doesn't return layername or field names -
displayFieldName: ""
feature: Object
attributes: Object
Pixel Value: "98.396004"
Stretched value: "92"
__proto__: Object
geometry: Object
infoTemplate: undefined
symbol: null
__proto__: Object
geometryType: "esriGeometryPoint"
layerId: 43
layerName: ""
Any ideas how to work round this - have I missed something here? Cheers ACM
... View more
02-20-2013
12:11 AM
|
0
|
0
|
905
|
|
POST
|
To add to this. Esri tend to take a world view of things, alas. To many, such as us in the UK, we take a local view. ALL our data is in WKID 27700 - British National Grid - which is a simpla(ish) XY system, in METRES (note spelling) from a point in the Atlantic. The only co-ordinate system most of our users will ever come across will be this. They need to be able to give co-ordinates out in metres and be able to get them in. Using Long Lats, or any other world projection just confuses the issue and I have to do conversions (in ArcIMS days 100+ lines of code, in AGS days, about 5) So please can the Measurement Widget be set to use the co-ordinate system of the map and return in the units it uses. Cheers ACM
... View more
02-14-2013
10:19 PM
|
0
|
0
|
1679
|
|
POST
|
If you are stuck on IE7 (bad luck) and can install IE plugins then rather than the one above (which looks interesting) why no go the whole way and use Google Chrome Frame which will give you the Chrome experiance, but within an IE container - which will remain IE for the majority of sites. I'm about to deploy this internally until we can get of XP/IE8
... View more
02-11-2013
09:11 AM
|
0
|
0
|
2045
|
|
POST
|
Thanks for that - I realize I probably need the projecyt method - however what the post was really about was the mis-match between thing and the snippet the (it is under the esri.geometry.lngLatToXY but the snippet is for XYTolngLat. Cheers ACM
... View more
02-07-2013
11:22 PM
|
0
|
0
|
1000
|
|
POST
|
OK - late in the day here but on http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_geometry/esri.geometry.lngLatToXY For esri.geometry.lngLatToXY(long, lat, isLinear) the example is
var normalizedVal = esri.geometry.xyToLngLat(42215329, 1321748);
console.log(normalizedVal); //returns 19.226, 11.789
var value = esri.geometry.xyToLngLat(42215329, 1321748, true);
console.log(value); // returns 379.22, 11.78 But the part for esri.geometry.xyToLngLat(long, lat) has no examples Am I just confused? All I am trying to do is use these to go from UK WKID (27700) to google map friendly co-ordinates (I realise there may be a small error, but all I need is a good approximation) Cheers ACM
... View more
02-07-2013
06:59 AM
|
0
|
3
|
1565
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-19-2026 12:29 AM | |
| 1 | 08-28-2025 01:14 AM | |
| 1 | 12-01-2023 06:07 AM | |
| 2 | 11-29-2024 04:32 AM | |
| 1 | 05-28-2024 12:50 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|