# Open cesium viewer pointing at a kml / kmz file?

**URL:** https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904
**Category:** CesiumJS
**Created:** [August 3, 2017, 4:51am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904 "2017-08-03T04:51:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Derek\_Chong](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Derek\_Chong](https://community.cesium.com/u/Derek_Chong)
#### Post date: [August 3, 2017, 4:51am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/1 "2017-08-03T04:51:46Z")

</div>

**Is there any way to create a url pointing at the cesium viewer with a kml file link that will open automatically?**

**Something like**

**[https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml](https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml) Open = [http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html](http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html)**

**Can’t find a way to embed the viewer in to Google Sites so just want to use a link for now.**

**Thanks**

**Derek**

---

<div class="post-metadata">

### Author: ![Jesse\_Reich](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jesse\_Reich](https://community.cesium.com/u/Jesse_Reich)
#### Post date: [August 4, 2017, 2:02am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/2 "2017-08-04T02:02:56Z")

</div>

I did this on my python Flask server using jinja 2 templating. I just pass the reference to the kml file as KMLFILE as a KmlDatSource.:

{% if KMLFILE %}

viewer.dataSources.add(Cesium.KmlDataSource.load(’{{KMLFILE}}’,options));

{% endif %}

---

<div class="post-metadata">

### Author: ![Derek\_Chong](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Derek\_Chong](https://community.cesium.com/u/Derek_Chong)
#### Post date: [August 4, 2017, 2:34am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/3 "2017-08-04T02:34:25Z")

</div>

Thanks Jesse but can’t host my own server for this one so just after a simple url solution

D

---

<div class="post-metadata">

### Author: ![Jesse\_Reich](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jesse\_Reich](https://community.cesium.com/u/Jesse_Reich)
#### Post date: [August 4, 2017, 2:51am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/4 "2017-08-04T02:51:25Z")

</div>

I don’t see the problem then. You should be able to add a KML Data Source using:

> Thanks Jesse but can’t host my own server for this one so just after a simple url solution

> D
> 
> > I did this on my python Flask server using jinja 2 templating. I just pass the reference to the kml file as KMLFILE as a KmlDatSource.:

> > {% if KMLFILE %}

> > viewer.dataSources.add(Cesium.KmlDataSource.load(‘{{KMLFILE}}’,options));

> > {% endif %}

> > > **Is there any way to create a url pointing at the cesium viewer with a kml file link that will open automatically?**

> > > **Something like**

> > > **[https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml](https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml) Open = [http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html](http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html)**

> > > **Can’t find a way to embed the viewer in to Google Sites so just want to use a link for now.**

> > > **Thanks**

> > > **Derek**

viewer.dataSources.add(Cesium.KmlDataSource.load(‘url’,options));

---

<div class="post-metadata">

### Author: ![Derek\_Chong](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Derek\_Chong](https://community.cesium.com/u/Derek_Chong)
#### Post date: [August 4, 2017, 3:18am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/5 "2017-08-04T03:18:38Z")

</div>

Mmm not sure if I have explained properly Jesse. This is what I am doing manually, but I just want to be able to do it with a single url I can send to someone to click on.

I currently click on this link to open the Cesium Viewer in Google Chrome

[http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html](http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html)

Then I drag and drop this .kml file into the viewer which displays it.

[https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml](https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml)

I would like to to be able to insert the kml link into the URL as an argument

[http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html](http://cesiumjs.org/Cesium/Build/Apps/CesiumViewer/index.html) [https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml](https://dl.dropboxusercontent.com/u/73681667/TheWarden/VIC/AWSNew/FWIChangeLive.kml)

I have zero web development experience so have to keep it simple.

Thanks

Derek

---

<div class="post-metadata">

### Author: ![Scott\_Hunter](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_hunter/32/2006_2.png) [@Scott\_Hunter](https://community.cesium.com/u/Scott_Hunter)
#### Post date: [August 4, 2017, 3:24am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/6 "2017-08-04T03:24:19Z")

</div>

CesiumViewer looks for a “source” query parameter and loads that automatically.

So …CesiumViewer/index.html?source=whatever

List of query parameter options is in the source:

[https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/CesiumViewer/CesiumViewer.js#L33](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/CesiumViewer/CesiumViewer.js#L33)

---

<div class="post-metadata">

### Author: ![Derek\_Chong](https://avatars.discourse-cdn.com/v4/letter/d/f19dbf/32.png) [@Derek\_Chong](https://community.cesium.com/u/Derek_Chong)
#### Post date: [August 4, 2017, 3:59am UTC](https://community.cesium.com/t/open-cesium-viewer-pointing-at-a-kml-kmz-file/5904/7 "2017-08-04T03:59:39Z")

</div>

Fantastic, just what I was looking for.

Thanks heaps Scott
