openlayers 3 - How to extrude height ol3-Cesium? -
i've got geojson can load in ol3 without problems.
var layer = new ol.layer.vector({ source: new ol.source.vector({ format: new ol.format.geojson(), url: 'my_file.json', }) });
my geojson have got properties (let's foo
) want use extrudedheight
.
i've done in cesium (see cesium exemple): http://cesiumjs.org/cesium/apps/sandcastle/index.html?src=geojson%20and%20topojson.html&label=showcases
but can't find way on ol3
layer.
any clue ?
edit:
i've hacked bit , create featureconverter this:
test = {}; function extend(base, sub) { // avoid instantiating base class setup inheritance // see https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/object/create // polyfill // also, recursive merge of 2 prototypes, don't overwrite // existing prototype, still maintain inheritance chain // @ccnokes var origproto = sub.prototype; sub.prototype = object.create(base.prototype); (var key in origproto) { sub.prototype[key] = origproto[key]; } // remember constructor property set wrong, let's fix sub.prototype.constructor = sub; // in ecmascript5+ (all modern browsers), can make constructor property // non-enumerable if define instead object.defineproperty(sub.prototype, 'constructor', { enumerable: false, value: sub }); } test.featureconverter = function(scene) { olcs.featureconverter.call(this, scene); } test.featureconverter.prototype = { olpolygongeometrytocesium : function(layer, feature, olgeometry, projection, olstyle) { olgeometry = olcs.core.olgeometrycloneto4326(olgeometry, projection); goog.asserts.assert(olgeometry.gettype() == 'polygon'); var rings = olgeometry.getlinearrings(); // update cesium externs before adding property var hierarchy = {}; var polygonhierarchy = hierarchy; goog.asserts.assert(rings.length > 0); (var = 0; < rings.length; ++i) { var olpos = rings[i].getcoordinates(); var positions = olcs.core.ol4326coordinatearraytocscartesians(olpos); goog.asserts.assert(positions && positions.length > 0); if (i == 0) { hierarchy.positions = positions; } else { hierarchy.holes = { // update cesium externs before adding property positions: positions }; hierarchy = hierarchy.holes; } } var fillgeometry = new cesium.polygongeometry({ // update cesium externs before adding property polygonhierarchy: polygonhierarchy, perpositionheight: true, extrudedheight: parseint(feature.getproperties()['foo']) }); var outlinegeometry = new cesium.polygonoutlinegeometry({ // update cesium externs before adding property polygonhierarchy: hierarchy, perpositionheight: true }); var primitives = this.wrapfillandoutlinegeometries( layer, feature, olgeometry, fillgeometry, outlinegeometry, olstyle); return this.addtextstyle(layer, feature, olgeometry, olstyle, primitives); } } extend(olcs.featureconverter, test.featureconverter);
but not work... (and not know why...).
Comments
Post a Comment