Select to view content in your preferred language

Opening KML File in active ArcMap Window

817
3
05-31-2013 12:47 PM
ZachBaker
Emerging Contributor
Hi,

I'm writing a program which needs to interface with ArcMap, I need to import a KML file and typically I would run it just by calling
ArcMap.exe <path to KML file>

The problem is, this loads a new session of ArcMap. Is there a way I can have it open in a copy currently running? I couldn't find any pages with commandline switches for ArcMap.

Thanks
0 Kudos
3 Replies
TerryGiles
Frequent Contributor
I don't think you can directly add KML to ArcMap (I could be wrong here), but you can use the KMLtoLayer tool to make a .lyr file in the user's temp folder and then add that layer.

It sounds like you're code is not running inside of ArcMap but another application.  If so, try using the AppROT class (in Esri.ArcGIS.Framework) to find ArcMap (if it's open) or to open ArcMap & add the layer created from the geoprocessing tool.
0 Kudos
ZachBaker
Emerging Contributor
I don't think you can directly add KML to ArcMap (I could be wrong here), but you can use the KMLtoLayer tool to make a .lyr file in the user's temp folder and then add that layer.

It sounds like you're code is not running inside of ArcMap but another application.  If so, try using the AppROT class (in Esri.ArcGIS.Framework) to find ArcMap (if it's open) or to open ArcMap & add the layer created from the geoprocessing tool.


^ I think that is exactly what I needed to hear.  That puts me in the right direction of where to look.
0 Kudos
DuncanHornby
MVP Notable Contributor
Zach,

As Terry indicated you want to be driving ArcMap using Automation, a similar question recently popped up on this forum thread. Try searching for the topic Automation on this forum and keywords like AppROT and IObjectFactory.

Duncan
0 Kudos