Giter Club home page Giter Club logo

Comments (9)

demux79 avatar demux79 commented on May 19, 2024 1

@geisterfurz007 Thanks, well spottet. I wish it made a difference. I tried all combinations with await only, then() only, both together. But the layer is never found.

UPDATE: It's the geojsonHeatmap.existsSync() that was causing the issue!

from mapbox-maps-flutter.

kamami avatar kamami commented on May 19, 2024

This can already be achieved with interpolate:

{
    "circle-radius": [
        "interpolate", ["linear"], ["zoom"],
        // zoom is 5 (or less) -> circle radius will be 1px
        5, 1,
        // zoom is 10 (or greater) -> circle radius will be 5px
        10, 5
    ]
}

from mapbox-maps-flutter.

irjayjay avatar irjayjay commented on May 19, 2024

Hi, thanks for your reply.

Yeah, we used to use interpolate for that.
I just couldn't find mention of any layer styles in the readme or demo app.
Now searching for interpolate in the project I see it gets used with layer styles once. A bit of hay in a needle stack.

Thanks for this! Perhaps it can be mentioned in the readme?
I think most devs new to Mapbox wouldn't be aware of layer styles or even think to search for them in the demo app.

from mapbox-maps-flutter.

yunikkk avatar yunikkk commented on May 19, 2024

@irjayjay hey, there's not a lot of docs about expressions usage at the moment (though seems you've found the animated route page that uses interpolate).
We'll definitely work on adding more!

from mapbox-maps-flutter.

irjayjay avatar irjayjay commented on May 19, 2024

Hi there. I think for expression usage a simple link to the mapbox docs would be fine.
I was referring more to mentioning in the readme that you can create layers and layer styles the traditional way.

But I see it's already there. I don't know how I missed that before.

Once again, thanks for all the great work!

from mapbox-maps-flutter.

demux79 avatar demux79 commented on May 19, 2024

Can this "traditional way" also be used for the HeatmapLayer?

With mapboxMap.style.setStyleLayerProperty I only get: Unhandled Exception: PlatformException(StyleError(rawValue: "Layer heatmap is not in style"), null, null, null)

from mapbox-maps-flutter.

geisterfurz007 avatar geisterfurz007 commented on May 19, 2024

@demux79 Make sure the layer is added to the styles before you try to set the style layer property; for that, make sure to await the call to addLayer.

from mapbox-maps-flutter.

demux79 avatar demux79 commented on May 19, 2024

@geisterfurz007 Hi, thanks for getting back to me. Unfortunately, I am already awaiting everything but still get the error. Do you have an idea? Also the styleSourceExists in line 6 is never true.

void _onStyleLoaded(StyleLoadedEventData styleLoadedEventData) async {
    await _addLayerAndSource();
  }

  Future<void> _addLayerAndSource() async {
    await mapboxMap?.style.styleSourceExists("source").then((exists) async {
      if (!exists) {
        // TODO: Is never called for unknown reasons
        // If source exists - just update it
        // final source = await mapboxMap?.style.getSource("source");
        // (source as GeoJsonSource).updateGeoJSON(json.encode(geojsonHeatmap));
        // } else {
        await mapboxMap?.style.addSource(GeoJsonSource(
            id: "source", data: geojsonHeatmap.readAsStringSync()));
      }
    });

    mapboxMap?.style.styleLayerExists("heatmap").then((exists) async {
      if (!exists && geojsonHeatmap.existsSync()) {
        await mapboxMap?.style.addLayer(HeatmapLayer(
          id: 'heatmap',
          sourceId: 'source',
          minZoom: 4.0,
          heatmapIntensity: 0.1,
          heatmapOpacity: 0.5,
          heatmapRadius: 30,
          heatmapWeight: 1.0,
        ));
      }
    });

    await mapboxMap?.style.setStyleLayerProperty('heatmap', 'heatmap-radius', 40);
  }

from mapbox-maps-flutter.

geisterfurz007 avatar geisterfurz007 commented on May 19, 2024

@demux79 There is one await missing at the second larger block in front of mapboxMap?.style.styleLayerExists.

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.