Giter VIP home page Giter VIP logo

Comments (4)

ben-xD avatar ben-xD commented on May 22, 2024 4

If we stick to using GeoJSON, won't we always have this problem? The 2 points mentioned in #20 (comment) can be ignored if we just drop the GeoJSON requirement.

I think users would have a nicer time if they use types rather than need to create untyped JSONs. Why don't we use types provided by library?

from mapbox-maps-flutter.

cedvdb avatar cedvdb commented on May 22, 2024

MapboxView & MapboxController would be more idiomatic

from mapbox-maps-flutter.

lukas-h avatar lukas-h commented on May 22, 2024

Hi @ben-xD,

you actually don't have to use turf here. The underlying data standard is GeoJSON. GeoJSON is itself based on JSON to represent geo data.
And if you want GeoJSON in a serialized Dart-representation, it consists of Maps, Lists, and numbers.

So the GeoJSON that you want to inject into the CameraOptions.center attribute can look like this (without turf library):

CameraOptions(
  center: {
    "type": "Point",
    "coordinates": [-80.1263, 25.7845]
  }
  // ...
),
// ...

Or isolated:

{
    "type": "Point",
    "coordinates": [-80.1263, 25.7845]
}

What turf simply provides, is an optional to use class-object representation of GeoJSON. Check it out in the README of the turf library https://github.com/dartclub/turf_dart.

The output of the Point.toJson method is the same Dart Map/List/number representation as shown in my example.

The benefits of using turf with Mapbox can be static analysis and runtime checks, to make sure if the GeoJSON data structures are valid.

from mapbox-maps-flutter.

lukas-h avatar lukas-h commented on May 22, 2024
LatLng center;

A new data type LatLng could add a lot of confusion, because:

  • It does not really correspond to the Point or Position/coordinate data type from the GeoJSON RFC standard, that Mapbox is using for the representation of the geo data.
  • The actual order of the Position's/coordinate's dimensions are: [LONGITUDE, LATITUDE, ALTITUDE (optional)] See here RFC. So to stay compliant with the GeoJSON standard regarding the order of the dimensions is important.

Though I totally see, that it would make sense to have more type information than just Map<String?, Object?> ("a Map with some String? keys and some Object? values")...

from mapbox-maps-flutter.

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.