Hello jsgeoda!

This chapter shows how to load jsgeoda library in Node.js, pure js(html page) and React. The jsgeoda_tutorial repository https://github.com/lixun910/jsgeoda_tutorial contains all the sample codes. You can clone the repository and run the examples locally.

git clone git@githbu.com:lixun910/jsgeoda_tutorial.git

Node.js

const jsgeoda = require('jsgeoda');

// create jsgeoda instance
const geoda = await jsgeoda.New();

// print out "Hello jsgeoda 0.0.8"
console.log("Hello jsgeoda", geoda.version);

Pure js

<html>
<head>
</head>
<body>
<script type="module">
import jsgeoda from 'https://cdn.skypack.dev/-/jsgeoda@v0.2.2-Lc34LnJ0L2k7CJpnhQri/dist=es2020,mode=imports/optimized/jsgeoda.js';
jsgeoda.New().then((geoda)=> {
    console.log('Hello jsgeoda', geoda.version);
});
</body>
</html>

React

import { StrictMode } from "react";
import ReactDOM from "react-dom";
// import jsgeoda library
import jsgeoda from "jsgeoda";

const rootElement = document.getElementById("root");

// jsgeoda.New() function will create an instance from WASM
// object that you can used later for spatial data analysis
jsgeoda.New().then((geoda) => {
  ReactDOM.render(
    <StrictMode>
      <div className="App">
        <h1>Hello jsgeoda!</h1>
        <h2>version: {geoda.version}</h2>
      </div>
    </StrictMode>,
    rootElement
  );
});

Try it yourself in the playground

Last updated