You're not missing anything, the feature layer doesn't provide the events you're describing. If you don't want to build this out yourself, you might want to look into tracking server: http://www.esri.com/software/arcgis/tracking-server/index.html
OK, time-series of dynamic point features being inserted ad-hoc by an external process into a database, I'd like to know (on the client-side) that new features (and how many) have been added since the last refresh. The way it's working at present is acceptable but it'd be much better to be able to distinguish between new and existing (temporally) features without providing my own state maintenance. If it can't be done 'out-the-box' then fair enough, I just want to make sure I haven't missed something in the API that I could hook into and/or some settings that would change the behaviour to provide this level of detail.
If you're using a layer from a map service as a feature layer, only new features are added. If your feature layer points to a feature service, all features are removed then added. Is the source for your feature layer a layer from a map service or a feature service?
Yes, this is expected because features are generalized on a per zoom level basis. See the "Feature Generalization" section of Feature Layer Best Practices.
I should have asked this before...can you expand on this workflow a bit? As you've found out, we don't provide events that fire for the specific addition of new features outside of events related to aplyEdits.
Then I'd update those features rather than removing and re-adding them...that's what I would have thought happens based on the above. If ALL the features are going to be removed then re-added regardless then what's the point of the OID in this scenario?
It also does a remove/add when zooming/panning to an existing feature, is that expected?
The crux of the issue is this:- what I really want is to know when a new feature has been added within the current extent and I can't see which of the public events would yield that information, is there a way to do this without having to initiate my own separate query/processing? (also knowing in future which have been removed/updated would be useful!)
That's as designed: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#refreshWhat if features have been modified since they were originally retrieved?
I would have thought that now it has a unique identifier for each feature calling refresh() on the layer wouldn't cause all features to be removed then redrawn, e.g. I'd have thought that only 'new' features i.e. with an OID not known to the client would be drawn and likewise the only features removed would be ones that are no longer in the JSON returned from AGS. I'm seeing ALL features being removed and then added which isn't very efficient!
How would adding a unique key be a surrogate?
Fulfilling the requirements for specific functionality isn't a hack.
We don't explicitly document that an object ID is required
but it is implied in that the main use case for feature layers is using data from ArcGIS Server.
As you've outlined, it's possible to publish data with AGS that doesn't have an object ID.
We'll update the docs.
A couple more questions: what's the mode for your feature layer? What kind of things are you wanting to do client side?
Creating a surrogate key where it's appropriate for the data is acceptable, but in this case it'd be a hack, the (identity) value would have no 'meaning' to the data values etc.
The underlying issue is that although the FeatureLayer JS knows that the data has no OID value (and logs this fact to the console) it continues to try and use it as a key to the data, I can point you towards the method(s) in the class where this causes issues if that helps?I understand the need for a key to identify data if, for example, I was providing some editing of persistable features, but in this case all I want to do is display the features in the map, just like the ArcGISDynamicServiceLayer would, but because I need some client-side functionality not available with an image-based layer type the FeatureLayer appeared to be the best choice....apart from this (rather severe) issue!
Hmm, I'm surprised to hear that. Can you talk a bit more about your data source? How is the data added to ArcMap? What's the data store being used for this data?
long,lat,message 1,1,hello world 2,2,hello again world
In that case, can you have your database auto-populate a unique field? All the main RDBMS's have this capability but you would probably have to create a new table and reload your data.
I can query against the source in ArcMap, specifically I'm doing some DateDiff stuff to limit the results.
The nature of the data means it would be dangerous to choose a key from actual data fields as it would remove records that in reality are not duplicates.
In that case, it's best to add your unique ID on the server. Does the layer have a primary key? Are you able to make selections against it in ArcMap?
Nope, the data are from an AGS map service...which is why I'm surprised that this does not 'just work' out of the box.
The forEach would run after you've retrieved your data but before you create your feature layer. Since it sounds like you're not using a layer from a map service, I assumed your creating a feature layer from a feature collection. Are you using a feature collection?
It's simple to add a unique field to your data client side. You can do it with three lines of code, something like: dojo.forEach(data, function(d, idx) { d.attributes.oid = idx; }); And in your feature collection, make sure your field named oid (or whatever you choose to name it) has a type of esriFieldTypeOID.
dojo.forEach(data, function(d, idx) { d.attributes.oid = idx; });
Derek, do you have any samples on how to do this?
What's the reasoning behind not wanting to add an object id field client side?
ArcCatalog connection information is usually kept in the hidden appdata folder for that user. With 10, you can now copy and paste the database connection item in the ArcCatalog data tree and paste it where you want it.
Try using a Query Layer to load the data into your MXD. Go to File -> Add Data -> Add Query Layer, connect to your database and write a query (or double-click on a table to Select *). Click "Show Advanced Options", then select one or more fields to create a unique identifier.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.