Select to view content in your preferred language

query map while loading

1333
6
Jump to solution
09-08-2014 06:20 AM
BhavinSanghani
Frequent Contributor

I want to highlight equipment on map as soon as it loads. I tried following approach and it works but I am looking for better apprach:

1) Load map

2) Add ArcGISDynamicLayer

3) As soon as ArcGISDynamicLayer is added, I use FeatureLayer.selectFeatures() to highlight the equipment.

The problem with this approach is it loads map twice. I am looking something where I can fire selectFeatures first and then supply required information to map so, in one call map can be loaded with the appropriate extent. Any example for this approach?  

0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Frequent Contributor

Hi Bhavin,

I have updated the fiddle to do add selection graphics instead of definition query.

Edit fiddle - JSFiddle

View solution in original post

0 Kudos
6 Replies
RiyasDeen
Frequent Contributor

Hi Bhavin,

Checkout this fiddle. Edit fiddle - JSFiddle

  • Create a feature layer
  • Query to get feature extent and object id
  • Create your map object with the feature extent as initial extent
  • Add the map service to map, Use object IDs collected to set definition query
0 Kudos
BhavinSanghani
Frequent Contributor

Hi Riyas,

setLayerDefinitions will filter out the features of particular layer and show only features which satisfies the filter criteria. It won't show other features on the same layer. I am looking for that.

I am looking to show all features of particular layer but highlight features which satisfies the criteria. e.g. Map needs to show all point features of Manhole layer but I want to highlight one Manhole feature with green color because it is matching the filter criteria. Is there any way to achieve this by requesting map only once with filter criteria + symbol definitions to highlight? To highlight features, I use selectFeatures() of FeatureLayer.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Can you simply apply a definition expression to the feature layer?  Ex:  Edit fiddle - JSFiddle

RiyasDeen
Frequent Contributor

Hi Bhavin,

I have updated the fiddle to do add selection graphics instead of definition query.

Edit fiddle - JSFiddle

0 Kudos
BhavinSanghani
Frequent Contributor

Jake/Riyas - thanks both of you for putting efforts to build the examples.

Loading feature layer before loading map looks good. I need to implement few more things on this scenario. I need to show acetates (e.g. measurements, lines, labels etc) as well when the map is loaded. I allow my customers to store acetates in the database. When user tries to open the map, I retrieve all stored acetates. Now, when they can be added on the map? Should I add them in map load event? Or there is a different approach?

0 Kudos
RiyasDeen
Frequent Contributor

Hi Bhavin,

By acetates if you are referring to adding graphics to map. Map load event would be the place when you start placing your graphics.

However, if you expect the number of graphics to be lot (say over 1000 odd points) it'll pull down your application performance.