How to use the geojs/annotation.pointAnnotation function in geojs

To help you get started, we’ve selected a few geojs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenGeoscience / geonotebook / js / src / map / geojs.js View on Github external
var annotation_layer = this.get_layer('annotation');
    var annotation;
    function _handler (evt) {
      annotation = evt.annotation;
    }
    annotation_layer.geoOn(geo_event.annotation.add, _handler);
    const coordinates = geojson.geometry.coordinates;
    const style = geojson.properties;
    _.defaults(style, {
      fillColor: style.rgb,
      fillOpacity: 0.8,
      lineWidth: 2
    });

    if (type === 'point') {
      annotation_layer.addAnnotation(pointAnnotation({
        position: {
          x: coordinates[0],
          y: coordinates[1]
        },
        style
      }));
    } else if (type === 'rectangle') {
      annotation_layer.addAnnotation(rectangleAnnotation({
        corners: _.map(coordinates[0], (coords) => {
          return {
            x: coords[0],
            y: coords[1]
          };
        }),
        style
      }));