1

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/h3-js@3.7.2/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) 

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.