maplibre/flutter-maplibre-gl

[BUG] "name" field doesn't match expected name "maplibre_gl " name: maplibre_gl_workspace : using Custom Style layer

Closed this issue · 6 comments

Platforms

all

Version of flutter maplibre_gl

0.20.0

Bug Description

I followed this documentation from MapTiler to integrate my custom vector style in map, when I used there example project with my style.json it was working, I commented and uncommented again to get package it is giving this error
Screenshot 2024-09-10 at 6 41 09 PM
Screenshot 2024-09-10 at 6 42 10 PM

Why am I using this?

  • When am I using package from pub.dev maplibre_gl, Wasn't able to load custom style through url
  • When I Use MapTiler demo app with my style url it is working perfectly fine
    using maplibre_gl
    Using Demo app with my style URl

Steps to Reproduce

  1. Clone repo from MapTiler demo [MapTiler Demo App Repo](git clone https://github.com/maptiler/get-started-flutter-maplibre-gl-js.git my-flutter-map)
  2. Replace styleUrl with your custom url
  3. Run the projects with flutter run
  4. Comment the '''maplibre_gl''' package in '''pubspec.yaml''' and uncomment it again
  5. Noticed this error
 Error on line 1, column 7: "name" field doesn't match expected name "maplibre_gl".
  ╷
1 │ name: maplibre_gl_workspace
  │       ^^^^^^^^^^^^^^^^^^^^^
  ╵
exit code 65

Expected Results

  1. Package should support custom style
  2. It should fix if impoting package via git

Actual Results

Screenshot_1725974387

Code Sample

class MapPage extends StatelessWidget {
  const MapPage({super.key});

  @override
  Widget build(BuildContext context) {
    return const Map();
  }
}

class Map extends StatefulWidget {
  const Map({super.key});

  @override
  State createState() => MapState();
}

class MapState extends State<Map> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: MaplibreMap(
        styleString: "$styleUrl",
        myLocationEnabled: true,
        initialCameraPosition: const CameraPosition(
            target: LatLng(
              13.067439,
              80.237617,
            ),
            zoom: 16),
        trackCameraPosition: true,
      ),
    );
  }
}

`
name: my_map
description: "A new Flutter project."

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
sdk: '>=3.2.3 <4.0.0'

dependencies:
flutter:
sdk: flutter

maplibre_gl:
git:
url: https://github.com/maplibre/flutter-maplibre-gl
ref: main

cupertino_icons: ^1.0.2

dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^3.0.1

flutter:

uses-material-design: true

`

I have checked, Its working fine with 0.19.0+2 but not with latest
0.20.0

Hi @amjad-raptee, the tutorial you linked is outdated. Please use maplibre_gl directly from pub.dev:

dependencies:
    maplibre_gl: ^0.20.0

If you need to use maplibre_gl from github, you need to set the path because the package got moved to a subdirectly:

    git:
      url: https://github.com/maplibre/flutter-maplibre-gl
      path: maplibre_gl
      ref: 0.20.0

I hope this information helps.

Hello @josxha thank for help, I have checked Pub.dev Documentation , It seems this is also outdated as you can see here
Screenshot 2024-09-11 at 11 52 51 AM
and this is running smooth with android but crashing on iOS
Screenshot 2024-09-11 at 11 54 29 AM

My style url is liike http://34.XY.XX.XXXX:XXXX/styles/test-style/style.json

also I'm using clean network traffic for iOS and Android
android:usesCleartextTraffic="true"

for iOS
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <!-- Add exceptions here if needed --> </dict>

also configured permission for iOS and Android
<key>NSLocationAlwaysUsageDescription</key> <string>This app needs access to location in the background to show your current location on map and send to your bike, also it enhance your SoS, Last Access, Search Location and calculate distance of your bike..</string>

While using 0.20.0 it is giving these error [HTTP] Request was successful (code = 200). D/Mbgl-HttpRequest(12234): [HTTP] This request was cancelled (http://xxxxyyyyy:8080/data/openmaptiles/0/0/0.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render.

same error for
/data/traffic.json
/data/chargers.json
/styles/test-style/sprite@2x.png

Screenshot_1726041894
@josxha While using my style url

Hello @josxha thank for help, I have checked Pub.dev Documentation , It seems this is also outdated

Thanks, I wasn't aware that there is an outdated get-started documentation in the API docs. Althrough it already uses pub.dev. I opened a pull request for a full documentation site in #461 but it isn't merged in yet.

[HTTP] Request was successful (code = 200). D/Mbgl-HttpRequest(12234): [HTTP] This request was cancelled (http://xxxxyyyyy:8080/data/openmaptiles/0/0/0.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render.

Sorry but this is not an error message. Ensure that your style is valid and try to debug it with the flutter dev tools.