KmlDataResource

296 views
Skip to first unread message

Quoc Vu

unread,
Feb 8, 2015, 9:37:23 PM2/8/15
to cesiu...@googlegroups.com
Hi, I need to get a layer handler of the image in the KML file after I loaded the KML file into KmlDataResource.  I need the layer so I can set the opacity of that image after the image was added to Cesium viewer.  Does anyone know how?  Thanks a lot

Quoc Vu

unread,
Feb 9, 2015, 10:11:34 AM2/9/15
to cesiu...@googlegroups.com
Here is the code:

  viewer = new Cesium.Viewer('cesiumContainer');
  kmlDataSource = new Cesium.KmlDataSource();
  kmlDataSource.loadUrl('myKMLFile');
  viewer.dataSources.add(kmlDataSource);

  var entities = kmlDataSource.entities.entities;
  var entity = entities[0];
  var rectangle = entity.rectangle;
  var material = rectangle.material;
  var image = material.image;
 
  How do I do this:

  image.alpha = Cesium.defaultValue(0.2, 0.2);

Thanks,

Matthew Amato

unread,
Feb 10, 2015, 1:19:26 PM2/10/15
to cesiu...@googlegroups.com
Unfortunately, it looks like there is currently no way to do this.I wrote up an issue so we don't forget about it: https://github.com/AnalyticalGraphicsInc/cesium/issues/2484

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Quoc Vu

unread,
Feb 11, 2015, 2:05:34 PM2/11/15
to cesiu...@googlegroups.com

Thanks Matthew.

I have another question.

As you know, after we load a KML file, we have a rectangle.material.image for the icon from that KML file.  Is there any way we can create an ImageryProvider with that rectangle.material or that rectangle.material.image.  Currently, we have to create an ImageryProvider with a URL only.

Thanks,

Matthew Amato

unread,
Mar 3, 2015, 2:01:39 PM3/3/15
to cesiu...@googlegroups.com
You can get the url and rectangle of the KML rectangle and construct a SingleTileProvider from that.

Something like this:
var url = rectangle.material.image.getValue();
var rectangle = rectangle.coordinates.getValue();
var provider = new Cesium.SingleTileImageryProvider({ url:url, rectangle:rectangle  });

Quoc Vu

unread,
Apr 6, 2015, 11:07:14 PM4/6/15
to cesiu...@googlegroups.com

Hi Matthew,

These codes worked fine for the old version, but after I downloaded the version 1.8, it failed.  Here are my source codes and urls:

    kmlDataSource.load(kml).then(function(dataSource)
    {
      var entities = dataSource.entities.values;
      var length = entities.length;

      var entity = entities[0];
      var rectangle = entity.rectangle;
      var url = rectangle.material.image.getValue();
      rectangle = rectangle.coordinates.getValue();
      var opacity = 1.0;
      var child = addAdditionalLayerOption(
              'Test',

              new Cesium.SingleTileImageryProvider({
                  url : url,
                  rectangle : rectangle
             }),
             opacity,
             true);
    });
  }

http://mwsci.jpl.nasa.gov/cesium-kml/Apps/kmlTest.html -- The old version worked fine:

and

http://mwsci.jpl.nasa.gov/cesium-1.8/Apps/kmlTest.html -- The new version 1.8 got the following error:  

An error occurred while rendering. Rendering has stopped.
TypeError: t is undefined l.intersection@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:417:28988 N.prototype._createTileImagerySkeletons@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:452:23606 M.processStateMachine@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:452:15115 N.prototype.loadTile@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:453:6024 _@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:453:18469 w.prototype.update@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:453:20030 K.prototype.update@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:453:31644 ct@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:457:2238 dt@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:457:2692 vt.prototype.render@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:457:8493 P.prototype.render@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:462:15618 t@http://mwsci.jpl.nasa.gov/cesium-1.8/Build/Cesium/Cesium.js:462:2643

I have looked up the code and I found that the new version 1,8 has added the Mine type to the kmlDataResource and didn't have the KmlDataResource.loadUrl()l function any longer, but I did use the KmlDataResource.load() instead.  It still had error.  Do you have any ideas.

Thanks,
--Quoc
 

TC-8, Matthew Amato wrote:

Matthew Amato

unread,
Apr 7, 2015, 4:29:01 PM4/7/15
to cesiu...@googlegroups.com
I wrote up this issue to address this: https://github.com/AnalyticalGraphicsInc/cesium/issues/2624 It's an easy fix and should be available in 1.9 (May 1st).

Quoc Vu

unread,
Apr 9, 2015, 12:42:44 AM4/9/15
to cesiu...@googlegroups.com

Thanks Matthew,
Reply all
Reply to author
Forward
0 new messages