GithubHelp home page GithubHelp logo

Comments (4)

nrabinowitz avatar nrabinowitz commented on July 19, 2024

The issue here has nothing to do with H3, but rather the way you are constructing the polygons for Google maps. Is there no way to simply use GeoJSON input?

If I understand your code correctly, you are assuming all polygon loops are outer loops. They are not - only the first polygon loop is an outer loop. Subsequent loops are holes (this is following the GeoJSON spec). So what you're seeing is that holes in your polygon are being shown as filled polygons, rather than being excluded. I don't know how to exclude holes in the Google maps framework you're using - I'll leave it as an exercise for the reader :).

from h3-js.

chris-eaton avatar chris-eaton commented on July 19, 2024

Thanks for your pointers - I have it working now.

If it always returns a GeoJSON object why allow a flag to be passed into the function?

from h3-js.

chris-eaton avatar chris-eaton commented on July 19, 2024

To help anyone else who finds this question here is the code to make this work:

        var megaPolygon = h3.h3SetToMultiPolygon(h3StringArray, true);

        var data = {
            type: "FeatureCollection",
            features: [{
                "type": "Feature",
                geometry: {
                    "type": "MultiPolygon",
                    "coordinates": megaPolygon
                }
            }]
        };

        this.mapObject.data.addGeoJson(data);```

from h3-js.

nrabinowitz avatar nrabinowitz commented on July 19, 2024

If it always returns a GeoJSON object why allow a flag to be passed into the function?

By default, the C library returns polygons with lat,lng points and without repeating the first point as the last point. The flag switches this to lng,lat points and closes loops by repeating the first point at the end, per the GeoJSON spec.

from h3-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.