1

I would like to draw a line binding a entity to its label with an offset. CesiumJS allows to offset the label, however its not possible to draw a line (or polyline) from a position to an offset like the red line in this image.

enter image description here

How can i do it? any sugestion?

i'm using pixel offset. but there is no problem to use eye offset

 labels.add({
        position: Cesium.Cartesian3.fromDegrees(-75.1641667, 29.9522222),
        text: 'Another label',
        pixelOffset: new Cesium.Cartesian2(100,-100)

    });
2
  • What kind of offset are you using? PixelOffset? Can you post code that creates the point and its label?
    – emackey
    Sep 21, 2015 at 21:16
  • replied on edit. Sep 22, 2015 at 11:45

1 Answer 1

2

The best way to do this is probably a billboard with an image of the line on it. The length will never change if it's a pixelOffset. You can put an image of a white line, and use the color property to set any other color.

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene;

var labels = scene.primitives.add(new Cesium.LabelCollection());
labels.add({
    position: Cesium.Cartesian3.fromDegrees(-75.1641667, 29.9522222),
    text: 'Another label',
    pixelOffset: new Cesium.Cartesian2(100, -100)
});

var billboards = scene.primitives.add(new Cesium.BillboardCollection());
billboards.add({
    color : Cesium.Color.RED,
    image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAyUlEQVR42u3RQRHAMBADsQRWwRRosBTMxSzqh3bGBKy19Hsz82QnG28UYQApw0ifV4owstczRRjZ9g4MGDBgCAYMwYAhGDAEA4ZgwIABAwYMGIIBQzBgCAYMwYAhGDBgwIABA4ZgwBAMGIIBQzBgCAYMGDBgwIAhGDAEA4ZgwBAMGIIBAwYMGDBgCAYMwYAhGDAEA4ZgwIABAwYMGIIBQzBgCAYMwYAhGDBgwIABA4ZgwBAMGIIBQzBgCAYMGDBgwKgDgVEGAqOoCyAqoIT32fmkAAAAAElFTkSuQmCC',
    pixelOffset: new Cesium.Cartesian2(50, -50),
    position : Cesium.Cartesian3.fromDegrees(-75.1641667, 29.9522222)
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.