POST
|
If I remove the existing layer, I can't then set it to null, since its removed from the collection. If I just remove the layer and add a new one, it also crashes randomly.
... View more
09-23-2015
07:12 AM
|
0
|
0
|
286
|
POST
|
I am having an issue with updating a KmlLayer in MySceneView.Scene.Layers. This is constantly updated at less than 30fps. I have multiple threads (max of 4) calling this function, each has a unique ID. The contents of the kml changes, but the URI remains the same (each thread also has its own kml with different Uri). The problem I'm having is that my application is randomly crashing after running for about a minute, and it's not telling my why. It just says MyProgram has stopped working. Monitor.Enter(MySceneView.Scene.Layers);
try
{
var kmlLayer = new KmlLayer(sourceUri); //sourceUri is a local file
kmlLayer.ID = id;
kmlLayer.Opacity = _alpha;
kmlLayer.IsVisible = _visibility;
kmlLayer.InitializeAsync();
if (MySceneView.Scene.Layers[id] != null)
MySceneView.Scene.Layers.Remove(id);
MySceneView.Scene.Layers.Add(kmlLayer);
}
finally
{
Monitor.Exit(MySceneView.Scene.Layers);
} Also tried replacing the layer instead of removing it, but it also crashes if (MySceneView.Scene.Layers[id] == null)
MySceneView.Scene.Layers.Add(kmlLayer);
else
{
for (int i = MySceneView.Scene.Layers.Count - 1; i >= 0; i--)
{
if (MySceneView.Scene.Layers.ID == id)
{
MySceneView.Scene.Layers = kmlLayer; //I cant replace the layer using the id as an index, since it's read only using a string index
}
}
} Any help would be appreciated
... View more
09-23-2015
06:58 AM
|
0
|
0
|
2753
|
POST
|
I have a piece of code that updates a KML overlay often. Some times, at random, my application crashes after replacing the KML layer from my Scene. I do not get an error message, not does it let me debug it, so I suspect is somewhere in the ArcGis code. Is this the correct way to update a KML layer? string id = objId + "Overlay";
System.IO.File.WriteAllText(_tempFilePath + @"\" + id + ".kml", kmlString);
var sourceUri = new Uri(_tempFilePath + @"\" + id + ".kml"); //I receive KML as a string, so I save as a file to get an URI
if (MySceneView.Scene.Layers[id] == null) //first time adding the layer
{
var kmlLayer = new KmlLayer(sourceUri);
kmlLayer.ID = id;
kmlLayer.Opacity = _alpha;
MySceneView.Scene.Layers.Add(kmlLayer);
return id;
}
else //Update the layer
{
for(int i = MySceneView.Scene.Layers.Count - 1; i >= 0; i--)//for each layer
{
if (MySceneView.Scene.Layers.ID == id) //find the matching ID
{
var kmlLayer = new KmlLayer(sourceUri);
kmlLayer.ID = id;
kmlLayer.Opacity = _alpha;
MySceneView.Scene.Layers = kmlLayer; //repalce the layer with the updated one
return id;
}
}
}
return "";
... View more
09-03-2015
12:45 PM
|
0
|
2
|
2745
|
POST
|
Morent, All I want is to specify the camera's position , and a second point, and have the camera look straight at that second point. I curently just calculate a pitch and a heading using the haversine formula Esri.ArcGISRuntime.Geometry.MapPoint mapPoint1 = new Esri.ArcGISRuntime.Geometry.MapPoint(cameraLon, cameraLat, cameraAlt);
Esri.ArcGISRuntime.Geometry.MapPoint mapPoint2 = new Esri.ArcGISRuntime.Geometry.MapPoint(targetLon, targetLat, targetAlt);
//get distance
double d = distance(cameraLat, cameraLon, targetLat, targetLon, 'K') * 1000;
double t1 = deg2rad(cameraLat);
double t2 = deg2rad(targetLat);
double dt = deg2rad(targetLat - cameraLat);
double dl = deg2rad(targetLon - cameraLon);
double alt = cameraAlt - targetAlt;
double pitch = 90 - rad2deg(Math.Atan2(alt, d));
//get heading
double y = Math.Sin(dl - dt) * Math.Cos(t2);
double x = Math.Cos(t1) * Math.Sin(t2) -
Math.Sin(t1) * Math.Cos(t2) * Math.Cos(dl - dt);
double heading = rad2deg(Math.Atan2(y, x)) + 45;
Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1, heading, pitch);
Viewpoint vp = new Viewpoint(camera, mapPoint2);
MySceneView.SetViewAsync(vp); I would like to not have to calculate the heading and pitch, since this is not always accurate.
... View more
08-24-2015
11:27 AM
|
0
|
0
|
384
|
POST
|
I have a function that constantly adds a new placemark graphic object with a PictureMarkerSymbol symbol, while deleting the previous one. When I create the first graphics object, the heading is correct. All the following placemarks have the angle of the first placemark ever created.I know the value of platformHeading changes, but the heading of my placemark stays constant. var graphicsOverlay = MySceneView.GraphicsOverlays["MyPlacemarkLayer"] as Esri.ArcGISRuntime.Controls.GraphicsOverlay;
Graphic graphic = new Graphic(new MapPoint(lon, lat, alt,MySceneView.SpatialReference));
Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol imgSym = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol();
imgSym.SetSourceAsync(new Uri(iconHref));
imgSym.AngleAlignment = Esri.ArcGISRuntime.Symbology.MarkerAngleAlignment.Map; //Does this even do anything
imgSym.Angle = platformHeading + _mapRotation; //I get _mapRotation when I move the map
ret = graphic.GetHashCode().ToString();
graphic.Symbol = imgSym;
//graphic.Attributes["Heading"] = _mapRotation + _mapRotation; //This doesn't do anything
MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.Add(graphic);
for (int i = 0; i < MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.Count; i++)
{
if (MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.GetHashCode().ToString() == oldId)
{
MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.RemoveAt(i);
break;
}
} I try to rotate the placemark when I move the screen, but this does'nt do anything at all. private void MySceneView_CameraChanged(object sender, EventArgs e)
{
_mapRotation = MySceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale).Rotation;
canvasBox.RenderTransform = new RotateTransform(360 - _mapRotation, canvasBox.Width / 2, canvasBox.Height / 2);
foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
{
foreach (Graphic g in gOverlay.Graphics)
{
g.Attributes["Heading"] = (double)g.Attributes["Heading"] + _mapRotation;
}
}
} In this example, I set my heading to be 45 and to increment by 5 every iteration. The placemark seems to get stuck at 45 forever. This is my WPF <Grid>
<Grid.Resources>
<esri:SimpleRenderer x:Key="MyRenderer">
<esri:SimpleRenderer.SceneProperties >
<esri:RendererSceneProperties
HeadingExpression="[Heading]"
PitchExpression="[Pitch]"
RollExpression="[Roll]" />
</esri:SimpleRenderer.SceneProperties>
<esri:SimpleRenderer.Symbol>
<esri:PictureMarkerSymbol AngleAlignment="Map" />
</esri:SimpleRenderer.Symbol>
</esri:SimpleRenderer>
</Grid.Resources>
<esri:SceneView x:Name="MySceneView" Visibility="Visible" LayerLoaded="MySceneView_LayerLoaded" CameraChanged="MySceneView_CameraChanged" >
<esri:Scene>
<esri:Scene.Surface>
<esri:ServiceElevationSource ServiceUri="http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" IsEnabled="True" />
</esri:Scene.Surface>
<esri:ArcGISTiledMapServiceLayer ID="BaseScene"
ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" />
</esri:Scene>
<esri:SceneView.GraphicsOverlays>
<esri:GraphicsOverlay ID="MyPlacemarkLayer" Renderer="{StaticResource MyRenderer}" RenderingMode="Dynamic">
<esri:GraphicsOverlay.SceneProperties>
<esri:LayerSceneProperties SurfacePlacement="Relative"/>
</esri:GraphicsOverlay.SceneProperties>
</esri:GraphicsOverlay>
</esri:SceneView.GraphicsOverlays>
</esri:SceneView>
</Grid>
... View more
08-17-2015
05:32 AM
|
0
|
0
|
2591
|
POST
|
I managed to get the elevation working, but the heading is still off. When I create the first graphics object, the heading is correct. This function is ran over and over, deleting the previous graphic, and adding a new one. All the new placemarks have the angle of the first placemark ever created. I also added MySceneView_CameraChanged to get the current rotation of the scene in order to correct the angle of the palcemark, but still nothing. var graphicsOverlay = MySceneView.GraphicsOverlays["MyPlacemarkLayer"] as Esri.ArcGISRuntime.Controls.GraphicsOverlay;
Graphic graphic = new Graphic(new MapPoint(lon, lat, alt,MySceneView.SpatialReference));
Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol imgSym = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol();
imgSym.SetSourceAsync(new Uri(iconHref));
imgSym.AngleAlignment = Esri.ArcGISRuntime.Symbology.MarkerAngleAlignment.Map; //Does this even do anything
imgSym.Angle = platformHeading + _mapRotation;
ret = graphic.GetHashCode().ToString();
graphic.Symbol = imgSym;
//graphic.Attributes["Heading"] = _mapRotation + _mapRotation; //This doesn't do anything
MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.Add(graphic);
for (int i = 0; i < MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.Count; i++)
{
if (MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.GetHashCode().ToString() == oldId)
{
MySceneView.GraphicsOverlays["MyPlacemarkLayer"].Graphics.RemoveAt(i);
break;
}
} private void MySceneView_CameraChanged(object sender, EventArgs e)
{
_mapRotation = MySceneView.GetCurrentViewpoint(ViewpointType.CenterAndScale).Rotation;
canvasBox.RenderTransform = new RotateTransform(360 - _mapRotation, canvasBox.Width / 2, canvasBox.Height / 2);
foreach (GraphicsOverlay gOverlay in MySceneView.GraphicsOverlays)
{
foreach (Graphic g in gOverlay.Graphics)
{
g.Attributes["Heading"] = (double)g.Attributes["Heading"] + _mapRotation;
}
}
} In this example, I set my heading to be 45 and to increment by 5 every iteration. The placemark seems to get stuck at 45 forever. This is my WPF <Grid>
<Grid.Resources>
<esri:SimpleRenderer x:Key="MyRenderer">
<esri:SimpleRenderer.SceneProperties >
<esri:RendererSceneProperties
HeadingExpression="[Heading]"
PitchExpression="[Pitch]"
RollExpression="[Roll]" />
</esri:SimpleRenderer.SceneProperties>
<esri:SimpleRenderer.Symbol>
<esri:PictureMarkerSymbol AngleAlignment="Map" />
</esri:SimpleRenderer.Symbol>
</esri:SimpleRenderer>
</Grid.Resources>
<esri:SceneView x:Name="MySceneView" Visibility="Visible" LayerLoaded="MySceneView_LayerLoaded" CameraChanged="MySceneView_CameraChanged" >
<esri:Scene>
<esri:Scene.Surface>
<esri:ServiceElevationSource ServiceUri="http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" IsEnabled="True" />
</esri:Scene.Surface>
<esri:ArcGISTiledMapServiceLayer ID="BaseScene"
ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" />
</esri:Scene>
<esri:SceneView.GraphicsOverlays>
<esri:GraphicsOverlay ID="MyPlacemarkLayer" Renderer="{StaticResource MyRenderer}" RenderingMode="Dynamic">
<esri:GraphicsOverlay.SceneProperties>
<esri:LayerSceneProperties SurfacePlacement="Relative"/>
</esri:GraphicsOverlay.SceneProperties>
</esri:GraphicsOverlay>
</esri:SceneView.GraphicsOverlays>
</esri:SceneView>
</Grid>
... View more
08-14-2015
11:40 AM
|
0
|
0
|
612
|
POST
|
My code generates a points that has a PictureMarkerSymbol. It is run over and over, and the previously generated graphic is removed and a new one is added (so it looks like the plane is moving, does not have to be a fluent animation). My issues is that I am able to add the initial heading of the symbol, so it has the correct heading, but the heading never changes afterwards. Also, when I rotate the map, the icon's heading seems to be fixed with the screen (always points to the same place with respect of the screen. Also, the altitude is always touching the ground. (same point looked from another angle) How do I make the direction of the icon always point to the real heading, and how can I have some elevation? My code: var graphicsOverlay = MySceneView.GraphicsOverlays["MyGraphicsOverlay"] as Esri.ArcGISRuntime.Controls.GraphicsOverlay;
if (graphicsOverlay == null)
{
graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.ID = "MyGraphicsOverlay";
}
//Convert from latlon to ArcGis Window coordinate
var scenePoint = new Esri.ArcGISRuntime.Geometry.MapPoint(lon,lat,alt,MySceneView.SpatialReference);
var pointSceneGraphic = new Esri.ArcGISRuntime.Layers.Graphic();
pointSceneGraphic.Geometry = scenePoint;
//set the graphic of the placemarker
Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol imgSym = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol();
imgSym.SetSourceAsync(new Uri(iconHref));
imgSym.AngleAlignment = Esri.ArcGISRuntime.Symbology.MarkerAngleAlignment.Map;
imgSym.Angle = platformHeading;
pointSceneGraphic.Symbol = imgSym;
ret = pointSceneGraphic.GetHashCode().ToString();
MySceneView.GraphicsOverlays[0].Graphics.Add(pointSceneGraphic);
foreach (var graphicsObj in graphicsOverlay.Graphics)
{
if (graphicsObj.GetHashCode().ToString() == oldId)
{
graphicsOverlay.Graphics.Remove(graphicsObj);
break;
}
} My WPF looks like this <Grid>
<esri:SceneView x:Name="MySceneView" Visibility="Visible" LayerLoaded="MySceneView_LayerLoaded">
<esri:Scene>
<esri:ArcGISTiledMapServiceLayer ID="BaseScene" ResamplingMode="None"
ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" />
</esri:Scene>
</esri:SceneView>
</Grid> Is there a better way to do what I'm doing?
... View more
08-13-2015
10:38 AM
|
0
|
4
|
3577
|
POST
|
I have a simple code that gets a Kml String, writes it to a file, and then adds it to the kmlLayer. In the KML strings I receive, I have a placemark that updates the position of a vehicle. Is there a way to efficiently update that Kml object constantly, without having to remove the KmlLayer and add a new one. It doesn't have to be a fluid animation, I just want to see the placemark updating quickly. My current implementation looks like this: public string AddKmlObject(KmlObject kmlObj, string folderPath, string oldObjectId)
{
try
{
if (kmlObj != null)//ArcGis does not support KML Strings, so I write KML into a file
{
System.IO.File.WriteAllText(_tempFilePath, kmlObj.ToKml());//Converts object to Kml Text
KmlLayer kmlLayer = new KmlLayer(new Uri(_tempFilePath));
kmlLayer.ID = kmlLayer.GetHashCode().ToString();
IkenaSceneView.Scene.Layers.Add(kmlLayer);
if (oldObjectId != "")
MySceneView.Scene.Layers.Remove(oldObjectId); //Remove previous Kml
return kmlLayer.ID;
}
}
catch
{
}
return "";
} Is there a better way to do this?
... View more
08-12-2015
12:41 PM
|
0
|
2
|
2824
|
POST
|
Is there a way to set the camera looking at a specific point in the scene without specifying a heading or pitch explicitly? I found a how to calculate pitch and heading using the haversine formula, but I was wondering if ArcGIS could do this for me. I want something similar to this: Esri.ArcGISRuntime.Geometry.MapPoint mapPoint1 = new Esri.ArcGISRuntime.Geometry.MapPoint(cameraX, cameraY, cameraAlt);
Esri.ArcGISRuntime.Geometry.MapPoint mapPoint2 = new Esri.ArcGISRuntime.Geometry.MapPoint(targetX, targetY, targetAlt);
Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1,0,0);
//or
//Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1,calculatedHeading,calculatedPitch);
Viewpoint vp = new Viewpoint(camera, mapPoint2); //camera looks at mapPoint2
MySceneView.SetView(vp); Thanks.
... View more
08-06-2015
09:12 AM
|
0
|
2
|
2513
|
POST
|
For anyone interested, I was able to make it work by adding the KML layer with MyMap.Layers.Add(kmlLayer); instead of MyMapView.Map.Layers.Add(kmlLayer); string file = @"C:\devel\test.kml";
KmlLayer kmlLayer = new KmlLayer(new Uri(file));
MyMap.Layers.Add(kmlLayer); I wasn't able to do it with a string, but a file is good enough.
... View more
08-04-2015
12:26 PM
|
1
|
0
|
474
|
POST
|
Just to be on the same page. What I want to do is similar as in this picture Can the KmlGroundOverlay class be used for this?
... View more
08-04-2015
07:39 AM
|
0
|
0
|
433
|
POST
|
Thanks, Mike. Is there a way to add this Kml from a string parameter or a local file in .Net? Also, can href be a local file?
... View more
08-04-2015
07:25 AM
|
0
|
0
|
433
|
POST
|
I've seen that similar questions have been asked, bust most of them are over a year old. Is there a way to add a KmlLayer from a KML string or a local file? I tried the following, but it only works when file is a url. string file = @"C:\devel\test.kml";
KmlLayer kmlLayer = new KmlLayer(new Uri(file));
MyMapView.Map.Layers.Add(kmlLayer);
... View more
08-04-2015
07:20 AM
|
0
|
2
|
2775
|
POST
|
I am new to the ArcGIS SDK and I can't seem to find how to add a picture on top of the map, using 4-coner coordinates. In the snippet below, coords has the coordiantes for 4 points. I know all I try to do in this example is to fill a polygon with a picture, so if anyone has an example on how to overlay a picture over the map, I would appreciate it. Thanks. System.Uri myPictureUri = new System.Uri("https://upload.wikimedia.org/wikipedia/commons/0/03/Piwnice_aerial_view.jpg");
Esri.ArcGISRuntime.Symbology.PictureFillSymbol pictureFillSymbol = new Esri.ArcGISRuntime.Symbology.PictureFillSymbol();
pictureFillSymbol.SetSourceAsync(myPictureUri);
var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as Esri.ArcGISRuntime.Layers.GraphicsLayer;
if (graphicsLayer == null)
{
graphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
graphicsLayer.ID = "MyGraphicsLayer";
MyMap.Layers.Add(graphicsLayer);
}
System.Collections.ObjectModel.ObservableCollection<Esri.ArcGISRuntime.Geometry.PointCollection> rings =
new System.Collections.ObjectModel.ObservableCollection<Esri.ArcGISRuntime.Geometry.PointCollection>();
Esri.ArcGISRuntime.Geometry.PointCollection pointCollection = new Esri.ArcGISRuntime.Geometry.PointCollection(MyMapView.SpatialReference);
for (int i = 0; i < coords.Length-2; i = i + 2)
{
Esri.ArcGISRuntime.Geometry.MapPoint point;
point = Esri.ArcGISRuntime.Geometry.ConvertCoordinate.FromDecimalDegrees(coords.ToString() + " " + coords[i + 1].ToString(), MyMapView.SpatialReference);
pointCollection.Add(point);
}
rings.Add(pointCollection);
//Set Geometry
Esri.ArcGISRuntime.Geometry.Polygon p = new Esri.ArcGISRuntime.Geometry.Polygon(rings, MyMap.SpatialReference);
var overlayGraphic = new Esri.ArcGISRuntime.Layers.Graphic();
overlayGraphic.Geometry = p;
overlayGraphic.Symbol = pictureFillSymbol;
graphicsLayer.Graphics.Add(overlayGraphic);
... View more
08-03-2015
12:46 PM
|
0
|
3
|
3595
|
Title | Kudos | Posted |
---|---|---|
1 | 08-04-2015 12:26 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|