How to use the @turf/center.default function in @turf/center

To help you get started, we’ve selected a few @turf/center 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 sharedstreets / sharedstreets-road-closure-ui / src / components / road-closure-map / index.tsx View on Github external
viewport: {
        latitude,
        longitude,
        zoom,
      }
    } = this.state;

    const mapboxInitConfig: any = {
      center: [longitude, latitude],
      container: 'SHST-Road-Closure-Map',
      style: 'mapbox://styles/mapbox/light-v9',
      zoom
    };
    if (AppExtent && AppExtent.length === 4) {
      mapboxInitConfig.bounds = AppExtent;
      mapboxInitConfig.center = center(bboxPolygon(AppExtent)).geometry.coordinates;
      mapboxInitConfig.zoom = 10;
    }
    this.mapContainer = new mapboxgl.Map(mapboxInitConfig);

    this.mapContainer.on('move', this.handleMapMove);
    this.mapContainer.on('mousemove', () => {
      // set pointer style to crosshair when isDrawing is toggled
      this.mapContainer.getCanvas().style.cursor = this.state.isDrawing ? 'crosshair' : '';
    })
    this.mapContainer.on('click', this.handleMapClick);
    this.mapContainer.on('mousemove', this.handleShowPossibleDirections)
    this.mapContainer.addControl(
      new mapboxgl.NavigationControl()
    );
    this.mapContainer.addControl(
      new MapboxGeocoder({
github geosolutions-it / MapStore2 / web / client / utils / AnnotationsUtils.js View on Github external
createGeometryFromGeomFunction: (ft) => {
        let type = geometryFunctions[ft.style.geometry] && geometryFunctions[ft.style.geometry].type || ft.geometry.type;
        let coordinates = ft.geometry.coordinates || [];
        switch (ft.style.geometry ) {
        case "startPoint": coordinates = head(coordinates); break;
        case "endPoint": coordinates = last(coordinates); break;
        case "centerPoint": coordinates = turfCenter(ft).geometry.coordinates; break;
        default: break;
        }
        return {type, coordinates};
    },
    /**

@turf/center

turf center module

MIT
Latest version published 4 months ago

Package Health Score

94 / 100
Full package analysis

Popular @turf/center functions