0.0.28 • Published 11 months ago

globe-sdk-leafet v0.0.28

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

Globe map sdk

Map sdk use only globe server

Installation

Use the package manager npm to install foobar.

npm i globe-sdk-leafet 
yarn add globe-sdk-leafet 

Usage

import React, { useEffect, useRef } from 'react';
import { MapSDK } from 'globe-sdk-leafet'; 
import "globe-sdk-leafet/dist/index.css";

const options: any = {
  map: {
    coordinates: {
      latitude: 0,
      longitude: 0
    }
  },
};

const MapComponent: React.FC = () => {
  const mapContainerRef: any = useRef(null);

  useEffect(() => {
    const mapSDK = new MapSDK(mapContainerRef.current);
    mapSDK.init(options);
    
    mapSDK.onShapeCreated((shape:any, layer:any) => {
      if (shape === 'Marker') {
        const geojson = layer.toGeoJSON();
        console.log(geojson);
      } else if (shape === 'Circle') {
        const geojson = layer.toGeoJSON();
        console.log(geojson);
      } else if (shape === 'Polygon' || shape === 'Rectangle' || shape === 'Polyline') {
        const geojson = layer.toGeoJSON();
        console.log(geojson);
      }
    });


    return () => {
      mapSDK?.destroy();
    };
  }, []);

  return (
    <>
      <div ref={mapContainerRef} style={{ width: '100%', height: '100vh' }} />
    </>
  )



};

export default MapComponent

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

0.0.20

12 months ago

0.0.21

12 months ago

0.0.22

12 months ago

0.0.23

12 months ago

0.0.24

12 months ago

0.0.25

12 months ago

0.0.15

12 months ago

0.0.16

12 months ago

0.0.17

12 months ago

0.0.18

12 months ago

0.0.19

12 months ago

0.0.10

12 months ago

0.0.11

12 months ago

0.0.12

12 months ago

0.0.13

12 months ago

0.0.14

12 months ago

0.0.26

12 months ago

0.0.9

12 months ago

0.0.27

12 months ago

0.0.8

12 months ago

0.0.28

11 months ago

0.0.5

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago