Select to view content in your preferred language

Defining map layers in defaultLayout - layers get cleared

5766
9
01-15-2014 09:05 AM
DannyVenier
Deactivated User
I'm trying to "pre-define" map layers, including a feature layer, in the defaultLayout.xaml configuration file, and/or creating layers dynamically, through C# code during initialization.

I'm not experienced with SharePoint but from tracing event flows, the application loads the defaultLayout, adds the esri:Map and any layers defined in there, but then during initialization, some configuration method calls a clear/reset on the layers collection and subsequently adds layers and content defined through the sharepoint/arcgis user interface (via add content, browse, add map layer etc).

It seems that the layers/content defined through the SharePoint UI supersedes anything defined in the layout (by clearing when it starts to load) yet I have no idea where the UI-defined layers are stored (I would assume  a XAML or XML config file but there are no files in our SP argis configuration files folder that hold that).  Configuring an XML file where the UI-defined stuff is stored would be just as suitable for my purposes but I can't find any such configuration.  Even doing it programmatically would be fine, but that goes away too unless I wait for a map loaded event to fire and for some unknown reason, it doesn't fire until I add a UI element to a container on the map, and I want to load earlier than that because there's a bit of data to load for the feature layer.

So the questions ....  Is there a config file that is accessible, and editable that holds the UI-defined content/layers definition?  If not, will deleting all the UI-defined ones prevent the config loader from clearing the layer collection on initialization? 

I'm open to any suggestion to meet my objective which is to create some layers, in particular a feature layer, in the initialization phase, layers that are not defined through the SharePoint/ArcGIS UI.

Any suggestions would be appreciated.

thanks,
Danny
0 Kudos
9 Replies
DannyVenier
Deactivated User
not meaning to bump the thread of my own question...however, without knowing the answer to my first post, I'm considering alternatives.

Without defining a feature layer in the layout/xaml, I could also make things work if I could change the feature layer renderer at runtime.  It would have to be "early" in the runtime so the user doesn't have to wait for the first feature set to download and render, only to have a new rendering start.

Unfortunately, I don't know the lifecycle of the ESRI application/map.  Silverlight reads defaultLayout, and sometime after that the ESRI config code reads (from somewhere unknown) the UI-defined content (map and layers), then at some point sees a feature layer and makes the REST call to get the features, and starts on initialization of extension elements, and then upon seeing the features loaded event, starts to render the features on the map.

Are there any useful events in that lifecycle that I could use to set the client renderer prior to the default rendering that follows the result from the GIS server? 

Is there documentation anywhere that give a bit of detail on the object lifecycles of the ESRI application/map?  Silverlight doesn't really have a rich lifecycle - seems like the only visible events are Initialization and Loaded events but does ESRI have any documentation describing it?  Yes, I have looked at the Map and Layer classes and there doesn't appear to be any visibility on additional events that can help me gain control prior to the initial rendering of a UI-defined feature layer.

Any assistance would be appreciated.

thanks,
Danny
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Danny,

The ArcGIS Map Web Part is designed to let you configure layers and then save those so that they appear the next time; Are you looking for functionality above and beyond this? If you need to specify the layers ahead of time via a configuration file you'll actually need to use the MapWebPartStartupMapDocument in the Configuration Files. http://doc.arcgis.com/en/maps-for-sharepoint/arcgis-map-web-part/configure-the-default-map.htm

Hope that helps,

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
DannyVenier
Deactivated User
Hi Katy,

thanks for the feedback. 
To answer your question, there is nothing exceptional that I have to do with the layer definition that I can't do with a configuration file.  I work in a arcGIS for Silverlight environment as well, where there is no SharePoint infrastructure and Map.xml is sufficient to define layers, renderers, symbols.

In SharePoint, however, I tried adding map layers to defaultLayout and through debugging I could see the layers were added on startup, but then a reset happened and they were removed (via a layer collection reset action). 

So if I could use MapWebPartStartupMapDocument to do the equivalent of Map.xml that would be perfect.  This makes sense. I did try to add some layers to the default version of that file in SP and the layers did not show up.  ( I tried adding to defaultLayout.xaml and then to MapWebPartStartupMapDocument.xml but it didn't add the layers.)  I already had some layers defined through the SharePoint "Add Content" UI so perhaps that was overwriting any layers in either of the two config documents (defaultLayout and MapWebPartStartupMapDocument).  I would expect that any UI-defined layers would just add to the MapWebPartStartupMapDocument configuration but it didn't work for me - just the UI defined layers showed up.

Is there some trick to setting MapWebPartStartupMapDocument as the default "Map.xml" config file?  Do I need to remove all other layers defined through "Add Content"?  Any references to examples of that file holding multiple layers?

In the interim, I have added listeners to the map layer collection during initialization, then assigned renderers at runtime in the initialization phase before the query task (which I can't access) goes out to get the features.  It works okay, but is not nearly as clean as a declarative approach like you suggest is possible.  I should mention that our particular application has a very large number of features prior to any search/filter and that causes long waits when loading which precludes me from loading first then changing renderers later.  We also have the need to use multiple attributes to map to a symbol and its rotation.


thanks again.  if you could point me to a sample or a reference document regarding MapWebPartStartupMapDocument, I'd really appreciate it.

Edit:  okay, just noticed the link you put in and it is exactly what I need to proceed.  thanks.

regards,
Danny
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Danny,

Our recommendation is that you use the UI to load layers whenever possible. In SharePoint, this means you have to have the map web part in Edit mode and then add the layers and then click OK or Apply on the properties pane (and you usually have to save the actual site page, too).

Now, it sounds like you have a Silverlight shop, which is fine, but we'd like to encourage you to begin looking at the JavaScript-based Esri Maps Web Part that was released with Esri Maps for SharePoint 3.0. The JavaScript-based web part is where we are focusing our development efforts for the future.

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
DannyVenier
Deactivated User
Katy,

Right, I am a Flex developer first, web developer (html5 toolset, javascript, java) second, and silverlight...somewhere after that.  I see Flex and Silverlight going away along with API support for those platforms, all driven by the mobile space.  Unfortunately, this is a big project, whose platform choices were made some time ago so I'm stuck with it for now.

I tried again "declaratively" defining Map and Layers in the MapWebPartStartupMapDocument.xaml and they didn't show up in the application.  I'm not sure why they didn't - no exceptions or complaints, just no layers.  It's not a great debugging environment in SharePoint.  I must be missing something.

It may be possible to do everything we want by defining the application through the SharePoint UI.  In the meantime, I'm just using a programmatic approach, listening on the layer creation of the UI defined layers and inserting properties to the layers there.  It is a bit tricky and I would say Silverlight has the worst object lifecycle I've ever seen, exposing almost nothing.

Anyhow, your suggestion to prefer the UI approach over the MapWebPartStartupMapDocument approach makes me wonder whether it is worth trying to use.  From a maintenance standpoint, moving between multiple environments, it would be much easier to maintain a config file per environment than going through the error prone UI configuration in each.  But if it doesn't work right....

thanks,
Danny
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Danny,

So the MapWebPartStartupMapDocument actually doesn't change existing map web parts, but is only applied when creating *new* map web parts.

Are you saying you don't want the end user to have to add a specific layer themselves? You could create a tool that they click to add the layer so they don't have to go searching for it? Actually you might do better with a behavior that looks to see whether the layer is there when the map loads and then adds it if not. That way there is no required user interaction. Options like that would be better than programmatically editing the xml files.

And with SharePoint, you can export/copy a site template to reuse...is this what you are talking about with moving between multiple environments?

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
DannyVenier
Deactivated User
Hey Katy,

Sorry for the tardy response to your last help, I have been a bit swamped. 
You are right in that I don't need the user to control layer creation themselves.  The requirement is all about an application requiring a rich symbology (multiple dimensions dependent on data attributes) that is difficult to configure using the SharePoint-UI.  Also, there are some limitations that I don't understand about pushing symbology in a feature layer when publishing and needing to search on feature layers and provide the same symbology on result layers.  Even setting the layer ID property is not possible using the SharePoint UI for defining layers, but is settable using a declarative approach like map.xml.

So, I am comfortable with the XAML or C# methods for binding symbols to features.  Ideally,this can be declared in the equivalent of a Map.xml  document in SharePoint that is used to add the map and layers to the application during application initialization.  When I talk about multiple environments, I mean that we run a sandbox, development, staging and production environment and each of those has its own networks and thus require different map, geometry and other specific features with unique service endpoints.  Having a Map.xml for each environment which has tweaks from a base map.xml would preclude us from having to hand configure (UI) each environment when we move the application through the deployment food chain.

I can define symbology and bindings in my project xaml files, and/or main layout file but the problem has been in assigning it during initialization before the first wave of feature layer data shows up and gets rendered.  The feature data getting and any events surrounding the initial request seem hidden from the programmer - I can only see load complete events so if I can't pre-define the feature layer and it's bindings in the map.xml equivalent, then I have to set them when the feature layer gets initialized, which is what I am doing now....but my preference, would be to define them in a place, like map.xml, which is the source of the application/map initialization.  It sounds like the MapWebPartStartupMapDocument is not that source. 

What I need, or want, I think, is the exact equivalent of the ArcGIS for Silveright's Map.xml but for the SharePoint environment - a configuration file, used on application/map initialization, to define layers, renderers, symbols, fields, mappings, bindings of symbols to fields, popups, etc......

thanks again,
Danny
0 Kudos
KatherineDalton
Esri Regular Contributor
Hi Danny,

Okay, so the MapWebPartStartupMapDocument.xaml file is the same idea as the Map.xml file from the SL Viewer. You should be able to add layers and renderers in there in almost the exact same way as the Map.xml file. The only thing is that it does *not* update existing web parts (there's an error in the doc that says it does update existing web parts). It only applies when creating new web parts. If you need a bit of guidance on how to structure the tags in the xaml file, you could create a map with most of the layers you need and then either view the page source or look at the page in SharePoint Designer.

And in terms of re-use, I think you could create a site template once you have the web part configured that could be pushed out to different environments. I've attached a Word doc with the basic instructions. The Word doc shows the UI instructions, but note that you can also do it via the command line (you can probably google for those instructions; they're pretty standard).

Hope that helps.

Katy
Katy Dalton | Technical Consultant
THE SCIENCE OF WHERE™
0 Kudos
CarstenVock
Emerging Contributor

Hello,

my question is a little off topic, but do you know how to use the OSM Layer as a starting layer?

The tag for ArcGIS Server Layers is: ArcGISTiledMapServiceLayer, but whats the tag for OSM Layers?

Thank you for Support!

Carsten

0 Kudos