I recently updated from Cesium 1.0 -> 1.19 and am utilizing DrawHelper to draw some regions on the map. I was using rectanglePrimitive which is now deprecated. I found a solution online that suggested changing to:
extent = new Cesium.Primitive({
geometryInstances : new Cesium.RectangleGeometry(),
appearance : new Cesium.EllipsoidSurfaceAppearance({
material : Cesium.Color.YELLOW.withAlpha(0.5),
})
});
I have tried a few different things and nothing seems to change the appearance of the rectangle during drawing. It stays invisible. DrawHelper used to draw a yellow rectangle with markers at each end, and now draws the markers but no material.
Does anyone know a solution to this?
Lets just say for now I am stuck with DrawHelper for now (since I need to be able to draw circles, rectangles, and polygons on the map 'by hand'). I have looked into solutions using entities and found that it would be quite difficult to do, or at least have not found a 'entity drawhelper' type plugin. I would love to use entities in a similar fashion as drawhelper uses primitives but again have not found anything.
It’s great for any type of primitives that have changing values. Look at this post for a code example of using a CallbackProperty to update positions for a wall:
DrawHelper is a third party plugin so we aren’t responsible for developing it. Unfortunately, it doesn’t look like the original developer is actively maintaining it. You could try forking the repo and updating it.
I am thinking I could possibly use DrawHelper as a template and refactor primitives to entites (and their callbacks and api), but cannot afford to waste days on this if its not possible. So fundamentally is it possible to extend the functionality of DrawHelper to Entities: Click to select a starting point, move mouse to create an area, click again to create entity. On paper this sounds easy but I am new to Cesium and do not now its limitations or how daunting a task this would be.
I’m not too familiar with their code, but yes I think that’s a good idea.
If the RectanglePrimitive is the only part of the code that’s not working, it should be an easy fix. You should be able to swap in a rectangle entity and change around attribute names. Just be sure to use a CallbackPropertry for rectangle.positions.