Select to view content in your preferred language

Flex API 2.4 KML support added - need sample of how to add kml

5354
26
08-01-2011 07:57 AM
DonCopple
Occasional Contributor III
I see kml support added and in the documentation it says the <layer> tag now supports type = "kml".

I have been trying to add that as a layer in my config.xml file as such:
<Layer> label="Mesowest Observations" type="kml" visible="false"
            url="http://www.srh.noaa.gov/gis/kml/mesowest/mesowestlink.kml"/>

I get an error on load Fault code: Client.CouldNotDecode
                             Fault info: Error #1085
                             Fault details: null

I cannot find any documentation on how to envoke the new layer easily, looks like I could go in and code something to load it, maybe.  Anyone else figured out how to add the kml layers?  I am combining kml and GIS layers.
Tags (2)
0 Kudos
26 Replies
SarthakDatt
Occasional Contributor III
Don,

As I mentioned in my earlier post, with the current FV 2.4 you would not see the network links whose default visibility is 0 unless you make that change to the TOCMapLayerItem.as

See the attached image, shows how the toc would look after the change is made. You would not have to manually set the visibility of each network link. It works fine with nested network links as well.

Regarding the features not shown on the map, I think there is a problem in the server not returning any renderer information. I am looking more into that. You can see the same by looking at the response in Firebug.
0 Kudos
SarthakDatt
Occasional Contributor III

One more point I noticed, no pop-ups in the included kml samples, of the online sample map. So if I click on the western railroads kml on the sample map, it does nothing. So if those popups need seperate xml files in the popups menu, and example of how to create those for a kml would be nice, once the kml is working.


You do not have to do anything specific, the kml layer comes with the popup info. I can see the popup on the western railroads kml at my end. I must agree the popups in this case are not well configured 🙂 :
0 Kudos
DonCopple
Occasional Contributor III
Did it render any points for you in your test.  I can open it in GE, so I know the server is working for GE, but not in Flex. 

I also appreciate the code, but am a beginner, so not sure how to impliment the code yet.  I have modified the config file, and have modified a couple of widgets, but that is as far as I have gotten with code experimentation.

Do I use the code you provide in the main application file?  Just not sure how to use it.  Sorry for my ignorance on the matter.  I will continue to hack away until I figure it out.

Thanks,
Don
0 Kudos
SarthakDatt
Occasional Contributor III

Did it render any points for you in your test. I can open it in GE, so I know the server is working for GE, but not in Flex.


No it did not, as "our" server is not returning any renderer info. This seems to be a bug. You can try your kml on arcgis.com and see the same result.


Do I use the code you provide in the main application file?


No, you would not be changing the main application file. In you viewer source code, you can go to com->esri->viewer->components->toc->tocClasses package and find TOCMapLayerItem.as. Now simply replace the methods in this file with the code I provided.
0 Kudos
PatrickTruitt
New Contributor
sdat,

I've noticed that the KML file must be Public in order for parsing. I work in an area that might require some sensitive kml data, any plans at ESRI to provide some local parsing?

Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sarthak,

   So this is what I am working on. I am adding KML Layer support to my TOC Widget that integrates legend swatches and TOC and I now have it working well. The one issue that remains (besides kml symbology looks much better in GE) is that if the KML does not specify a default symbol than you guys give it a default symbology (which is fine), but then you never provide anything to the getLegendInfos function. Just thought you should know from a developers perspective what is not working.
0 Kudos
DonCopple
Occasional Contributor III
Thanks for working on this too Robert.  Hope the bugs get worked out soon. 

Thanks also for letting me know where to put the code.  Will try that adn see what happens.



OK, I implemented to code change, which brings up the TOC, however, the points come up as (?).  So not sure if the kml is being parsed correctly or not.  I will have to look through the code to see which part returns a (?) if there is an error I guess.  So it looks as if there is still a bug.  My screen shot is below, and I am working with the publically availible kml here:http://www.srh.noaa.gov/gis/kml/SpotForecast/spotLink.kml

Here's my screen shot, so you can see TOC now works, just not being rendered on the map.
0 Kudos
ErikArchibald
New Contributor
sdat,

I've noticed that the KML file must be Public in order for parsing. I work in an area that might require some sensitive kml data, any plans at ESRI to provide some local parsing?

Thanks.


I'm having this problem too.   I'd like to have all my KML hosted on an intranet.  Any ideas for a work-around?
0 Kudos
DonCopple
Occasional Contributor III
Sarthak,
Just a quick update to my comment about the popup for the kml.  I opened the same western rr kml file in GE, it gives much more information than the popup that does work in flex.  So I think it is the way that is being parsed also.  I hope to get the other stuff working, but also need the pop ups to work as well.  A lot of the data that are included with the KML's I am trying to load are included in the pop up that comes up with the point on the map.

I included a screen shot of the same rr kml that comes with the example viewer kml, but it shows much more data in the pop up.  Any ideas on how to create the pop up?

Maybe Robert is working on this with his Widget as well though.  Sorry to keep bugging you, but I am in need of this to work.....

Still just have a (?) for my kml layers too, haven't figured that out, no display on the map, but is in the TOC.  Could it be something with the map datum, and kml file differences?

Thanks,
Don
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Don,

   I tested several links for the http://www.srh.noaa.gov/gis/kml site and could not get a one of them to work either but I have had good success with other kmls so I would say for the time being look else where for kml data you can use, as it is unlikely that the issue will get resolved without another release of the API and or viewer.
0 Kudos