KML/KMZ data support in ArcGGIS API for Javascript

5303
8
04-28-2011 08:32 AM
venk
by
New Contributor
Dear all,

    We are planning on researching on ArcGIS API for Javascript for viewing KML files on the ArcGIS maps. As it is a known fact that we having thousands of KML's being produced all over the world and google Earth being an Enterprise product, we want to research if we could use this API to build a KML viewer for viewing any KML files on web pages.

  I would appreciate your expert opinion on possibilities and views.

Thanks
0 Kudos
8 Replies
RickZawadzki
New Contributor
You absolutely can! I can't speak for the general Javascript API as I've been using the ArcGIS Extension for the Google Maps API in combination with the Google Maps API. However, I can say that the Google Maps API will allow you to add a KML / KMZ overlay without any ESRI tools or API usage. You would just need to provide the URL for the KML when creating a new overlay.

If you rather pull your KML/KMZ from the ArcGIS Server on a more dynamic basis then you will need to also utilize the extension api, but, the plus side is that you can also do far more than what the Google Maps API allows for on its own.

I'm sure other folks have better experience with the standard ArcGIS API for Javascript, but my guess is that the two probably have feature parity with one another. Hope that helps!
0 Kudos
MarkHoover
Occasional Contributor II
I just spoke with an ESRI Technical Support person about this earlier this week.  This is not natively supported in the ArcGIS API for JavaScript at this time, though there are plans for support in the future (no telling when).

However, because KML is just a markup language, it could theoretically be read in (maybe with the dojox.xml namespace?) and added to the map on a graphics layer.  Not ideal at all, and would take a bit of work (haven't implemented this myself) but if it's mission critical and you want to use the ArcGIS API for JavaScript, I think this is what you have to do at this time.

Of course, if I'm wrong, someone else should feel free to speak up 🙂
0 Kudos
MichaelPorter1
New Contributor III
One option might be to write a geoprocessing service that leverages existing tools within arcmap that convert KML to shapefiles, etc.
0 Kudos
RajendraShelar
New Contributor
Hi,
  Its good effort by ESRI to support KMLLayer. but it seems spatialreference param does not working. My map and kml are in different projection system. i tried to use optional param but no change.
pls let me know how i can change projection of kml.

P.S. Rest API is working. if i put outSR = 3414 with http://utility.arcgis.com/sharing/kml then it is able to convert coords as per 3414.


thank you in advance


Version 2.4 of the API supports KML data via the KMLLayer class.

Samples:
ArcGIS API for JavaScript:  KML Layer
ArcGIS API for JavaScript:  KML Layer with buffer
0 Kudos
derekswingley1
Frequent Contributor
My map and kml are in different projection system. i tried to use optional param but no change.


Are you specifying outSR in the KMLLayer constructor? Your code should look something like this:

var kmlLayer = new esri.layers.KMLLayer(kUrl, { 
  outSR: new esri.SpatialReference({ wkid: 26912 }) 
});
0 Kudos
ermiastesfamariam
New Contributor II
That worked for me. Thanks Swingley! Do you know how I can retrieve the original styles of the KML features?

Are you specifying outSR in the KMLLayer constructor? Your code should look something like this:

var kmlLayer = new esri.layers.KMLLayer(kUrl, { 
  outSR: new esri.SpatialReference({ wkid: 26912 }) 
});
0 Kudos
NitinShinde
New Contributor
I am doing as per your suggestion, but still i am getting following error...
"KMLLayer:_setMap - unsupported workflow. Spatial reference of the map and kml layer do not match, and the conversion cannot be done on the client."
0 Kudos