Skip to content

Executing Geojson2h3 on the browser without Nodejs #28

@sharmapn

Description

@sharmapn

I am trying to execute Geojson2h3 on the client browser without Nodejs. I have imported the 'geojson2h3.js' javascript file
However, I am getting an error with the following code.
I am hoping that this is possible to execute geojson2h3 in the browser.

<script src="assets/js/geojson2h3.js"></script>
<script src="assets/js/h3binning.js"></script>		
<script src="https://unpkg.com/h3-js"></script>
<script src="https://unpkg.com/[email protected]/dist/h3-js.umd.js"></script>

function h3binning(){     
    var filename = "sample.geojson"
    var geoJSON = { "type": "FeatureCollection",
    "features": [
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
        "properties": {"prop0": "value0"}
        }
      ]
    }

    console.log('geoJSON: geoJSON' )
    console.log('JSON.stringify(geoJSON): ' + JSON.stringify(geoJSON) )
        
    const hexagons2 = geojson2h3.featureToH3Set(geoJSON, 10); //binning level.  
}

I receive this error.

Uncaught ReferenceError: geojson2h3 is not defined
    at h3binning (h3binning.js:61:23)
    at HTMLButtonElement.<anonymous> ((index):467:22)
    at HTMLButtonElement.dispatch (jquery-3.6.0.min.js:2:43064)
    at v.handle (jquery-3.6.0.min.js:2:41048) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions