0

In Flutter there is availability of one package which cost more than 6k USD per year, looking a affordable method for Flutter to show shapefile in a Flutter app with data lines between continents and countries of cable lines data, no idea in Google Map, anyone working in 2022?

this is my shapefile after converted json

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates":
                [
                  [
                    [
                      -21.762688, 130.074418
                    ],
                    [
                      -17.165066, 130.338266
                    ],
                    [
                      -16.027996, 135.043554
                    ],
                    [
                      -18.836765, 138.913324
                    ]

                  ]
                ]

      },
      "properties": {
        "OBJECTID": 56795346,
        "GEOM_SRCE": "Mapping",
        "SHAPE_LEN": 16845.57375075535
      }
    }
  ]
}

i trying to show these datas in any map in flutter ??!!

3
  • 1
    Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works Commented Jun 1, 2022 at 8:19
  • Is there a specific reason for wanting to use shapefile? Commented Jun 1, 2022 at 9:36
  • user given shapefiles only . i just converted into json , from( json data or csv data ) any way to show the datas on map ? Commented Jun 1, 2022 at 9:42

1 Answer 1

1
To display the data from your shapefile on a map in Flutter, you can use the flutter_map package. Here are the steps you can follow:

Add the flutter_map package to your dependencies in pubspec.yaml:
yaml


 dependencies:
      flutter_map: ^0.14.0

Import the package in your code:


 dart
 
    import 'package:flutter_map/flutter_map.dart';


Create a new FlutterMap widget and add a TileLayerWidget to display a map tile layer:
dart



  FlutterMap(
      options: MapOptions(
        center: LatLng(-20, 133), // Center the map on your desired coordinates
        zoom: 5, // Set the initial zoom level
      ),
      layers: [
        TileLayerWidget(
          options: TileLayerOptions(
            urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            subdomains: ['a', 'b', 'c'], // Add subdomains for the tile layer
          ),
        ),
      ],
    )

Add a PolylineLayerWidget to display the shapefile data on the map:
dart



 FlutterMap(
      // ...
      layers: [
        // ...
        PolylineLayerWidget(
          options: PolylineLayerOptions(
            polylines: [
              Polyline(
                points: [
                  LatLng(-21.762688, 130.074418),
                  LatLng(-17.165066, 130.338266),
                  LatLng(-16.027996, 135.043554),
                  LatLng(-18.836765, 138.913324),
                ],
                color: Colors.blue, // Set the color of the polyline
                strokeWidth: 3, // Set the width of the polyline
              ),
            ],
          ),
        ),
      ],
    )

This will display a map with a tile layer from OpenStreetMap and a polyline layer showing the shapefile data. You can customize the appearance of the map and the polyline to suit your needs.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.