Graphics get lost

1835
10
Jump to solution
03-13-2014 08:17 AM
Labels (1)
Cristian_Galindo
Occasional Contributor III
DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far???

I have created an ArcGISLocalFeatureLayer with a different spatial reference from the base layer, then I create a polyline that is added to the Graphics container of the layer.

As my data is in another spatial reference, I remove the layers from the map, change the spatial reference of the map and add the layers again.

Then I add the new layer (the one with the polyline)...at this moment the Graphics property onf the layer turns to 0, it just dissapear!!

maybe my code is haunted....

any suggestions??? where my polyline goes? why the polyline appear in the map (i can view the line in my screen) but not in the Graphics list
0 Kudos
1 Solution

Accepted Solutions
Cristian_Galindo
Occasional Contributor III
I figure this:

You have to be aware of the layer's lifecycle:

first the layer must be created.....
var myLayer = new ArcGISLocalFeatureLayer(); // all code required to create it

then initialize it
myLayer.Initialize();
  ....and wait
When it finish to initialize (myLayer.Initialized event).....
you must update it
myLayer.Update();
  .....and wait again...
When it finish to update (myLayer.UpdateCompleted event)....Voila!!!! you have your Graphics!!! my code was not haunted!!!!

View solution in original post

0 Kudos
10 Replies
BKuiper
Occasional Contributor III
If i remember correctly, the projection of the Map can not be changed after it has been set, even after you have removed all the layers. You will need to create a new Map object and set the projection.

note that this is the behavior in the WPF SDK as far as i know.

It might that you have ran into some issues that are a result of you doing something that the Map object doesn't support.
0 Kudos
Cristian_Galindo
Occasional Contributor III
If i remember correctly, the projection of the Map can not be changed after it has been set, even after you have removed all the layers. You will need to create a new Map object and set the projection.


Sorry to tell you this: that is possible.
0 Kudos
Cristian_Galindo
Occasional Contributor III
I figure this:

You have to be aware of the layer's lifecycle:

first the layer must be created.....
var myLayer = new ArcGISLocalFeatureLayer(); // all code required to create it

then initialize it
myLayer.Initialize();
  ....and wait
When it finish to initialize (myLayer.Initialized event).....
you must update it
myLayer.Update();
  .....and wait again...
When it finish to update (myLayer.UpdateCompleted event)....Voila!!!! you have your Graphics!!! my code was not haunted!!!!
0 Kudos
BKuiper
Occasional Contributor III
Sorry to tell you this: that is possible.


I'm pretty sure it is not. In the WPF SDK, after you have loaded your first layer and projection of the Map object is set, the Map projection can not be changed to another projection. Either way, you have solved your problem. I just want to make sure people are aware of this possible caveat in WPF SDK.
0 Kudos
Cristian_Galindo
Occasional Contributor III
I'm pretty sure it is not. In the WPF SDK, after you have loaded your first layer and projection of the Map object is set, the Map projection can not be changed to another projection. Either way, you have solved your problem. I just want to make sure people are aware of this possible caveat in WPF SDK.


I just did it
0 Kudos
BKuiper
Occasional Contributor III
which version of the WPF SDK are you using?
0 Kudos
Cristian_Galindo
Occasional Contributor III
which version of the WPF SDK are you using?


I am using 10.2
0 Kudos
BKuiper
Occasional Contributor III
Could you give me an example how you reset the projection (spatialreference) of the Map? I have tested it here and discussed this in the past with the Runtime team. If i load a basemap with projection 102100, remove it and then load a basemap with projection 4326 the new basemap won't be visible because the actual projection of the map hasn't changed. So the TPK can not be displayed. Even if I set Map.Extent to the (Full)Extent of the new basemap.
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi Bjorn,

It is possible to change the Map SpatialReference by clearing the layers and defining a new Extent (Envelope) with a different SpatialReference.

e.g.

MyMap.Layers.Clear();

MyMap.Extent = new ESRI.ArcGIS.Client.Geometry.Envelope()
{
SpatialReference = new SpatialReference(102067),
XMin = -761340,
YMin = -1348150,
XMax = -438251,
YMax = -997291
};

MyMap.Layers.Add(new ArcGISTiledMapServiceLayer()
{
Url = "http://geo.kr-jihomoravsky.cz/ArcGIS/rest/services/JMK/jmk_raster/MapServer/",
});

However, I will confirm with the developers whether this is advisable or if it is better to create a new map instance (which is what you were advised in the past).

Cheers

Mike
0 Kudos