[cesium-dev] kml in cesium?

There are multiple problems with your code.

  1. You are using double quotes inside of your string which is also defined with double quotes.

  2. You aren’t properly escaping new lines

  3. You are using CzmlDataSource instead of KmlDataSource

  4. KmlDataSource doesn’t take a string, only a url or parsed Document.

Here’s what the working code looks like:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var testkml=’<?xml version="1.0" encoding="UTF-8"?>\

\

\

\

New point\

This is a new point.\

\

\

135.2, 35.4, 0.\

\

\

\

\

';

var parser = new DOMParser();

viewer.dataSources.add(Cesium.KmlDataSource.load(parser.parseFromString(testkml, “text/xml”)));