POST
|
ok. Sorry to clog up the forums. Seems the problem was with my kml and esri not liking how I defined my style(s): <name>Countries</name>
<Style id="Clear">
<LineStyle>
<color>00ffffff</color>
<width>2</width>
</LineStyle>
<PolyStyle>
<color>00ffffff</color>
<colorMode>random</colorMode>
</PolyStyle>
</Style>
<Placemark>
<name>Canada</name>
<styleUrl>
#Clear
</styleUrl>
<MultiGeometry>
.
.
.
</MultiGeometry> Returns a white-filled polygon. This on the otherhand: <name>Countries</name>
<Placemark>
<name>Canada</name>
<Style>
<PolyStyle>
<color>00ffffff</color>
</PolyStyle>
<LineStyle>
<color>00ffffff</color>
<width>1</width>
</LineStyle>
</Style>
<MultiGeometry>
.
.
.
</MultiGeometry> Returns a clear polygon, which is what I was looking for. Looks like I've got some reformatting to do....
... View more
01-27-2012
07:25 AM
|
0
|
0
|
401
|
POST
|
Hello Jennifer, The code you posted doesn't seem to do anything (at least it doesn't in the way I implemented it): Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim theKmlLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer = CType(Map1.Layers("MyGraphicsLayer"), KmlLayer)
Dim fillsymbolcolor As New SimpleFillSymbol
fillsymbolcolor.Fill = New SolidColorBrush(Color.FromRgb(255, 0, 0))
For Each kl As GraphicsLayer In theKmlLayer
For Each g As Graphic In kl.Graphics
If CStr(g.Attributes("name")) = "United States" Then
g.Symbol = fillsymbolcolor
End If
Next
Next
Dim l = TryCast(Map1.Layers("MyGraphicsLayer"), KmlLayer)
Dim f = l.Graphics.FirstOrDefault
Dim s = TryCast(f.Symbol, SimpleFillSymbol)
s.Fill.Opacity = 0.3
End Sub and my xmal: <Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
<Grid>
<esri:Map Background="White" Name="Map1" WrapAround="True">
<esri:Map.Layers>
<esri:LayerCollection>
<esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
<esri:KmlLayer ID="MyGraphicsLayer" Url="C:\junk\SiteMap5.Kml" VisibleLayers="Polygons"/>
</esri:LayerCollection>
</esri:Map.Layers>
</esri:Map>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="12,145,0,0" Name="Button1" VerticalAlignment="Top" Width="75" />
</Grid>
</Window> The shapes still have a solid white or red fill (depending on if the shapename is "United States" or not). Do all imported kml files have a default fill of white? Any other thoughts or feedback is greatly appreciated. Thanks!
... View more
01-27-2012
05:03 AM
|
0
|
0
|
401
|
POST
|
Thanks for the nudge Jennifer, I'll give it a whirl today and post back if I have any questions.
... View more
01-27-2012
01:27 AM
|
0
|
0
|
401
|
POST
|
Hello, Hopefully one last question. I've got my kml file to load, and I can set the color based on an attibute, but here's my problem...When my KML file is loaded, all of the polygons are filled white. I can lessen it by setting the whole kml layer opacity to .5, but once the color is applied, the remaning countries are filled with white. A workaround I came up with is: Dim theKmlLayer As ESRI.ArcGIS.Client.Toolkit.DataSources.KmlLayer = CType(Map1.Layers("MyGraphicsLayer"), KmlLayer)
Dim fillsymbolcolor As New SimpleFillSymbol
Dim fillsymbolclear As New SimpleFillSymbol
fillsymbolcolor.Fill = New SolidColorBrush(Color.FromRgb(255, 0, 0))
fillsymbolclear.Fill = New SolidColorBrush(Color.FromArgb(0, 0, 0, 0))
theKmlLayer.Opacity = 0.5
For Each kl As GraphicsLayer In theKmlLayer
For Each g As Graphic In kl.Graphics
If CStr(g.Attributes("name")) = "United States" Then
g.Symbol = fillsymbolcolor
Else
g.Symbol = fillsymbolclear
End If
Next
Next but surely there's a way to have the kml file itself come in w/ clear polygons. If anyone is interested, my kml file is attached. Ideally, I'd like to KML file to load w/ the polygons not being filled rather than having to loop through every one and apply a clear fill to it. Thanks in advance!
... View more
01-26-2012
11:42 AM
|
0
|
4
|
3176
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|