sharemap_maplib_flutter

A MapLibre-based map widget for Flutter integrating ShareMap APIs. This package simplifies the integration of map tiles, dynamic POI layers (such as industrial zones, ports, stations), and style loading with API key authentication and HMAC signature signing.

Features

  • Automated POI Layers: Automatically handles registration of VectorSource and styling for different POI types (Fill, Outline, Circle, and Symbol layers) under the hood. No manual JSON parsing or boilerplate layer logic required.
  • HMAC Signature Signing: Seamlessly calculates dynamic Base64 HMAC signatures for secure style loading requests.
  • Deep Compare Optimization: Prevents map reloads or redundant network request loops (abort/red tiles issue) by leveraging deep list comparisons on dynamic layerCodes.
  • Environment Modes: Switch between dev and prod modes for different tileserver environments with debug mode logging capabilities.
  • Custom Tile Support: Easily integrate external MVT tileservers by passing direct URLs.

Getting started

Add the package to your pubspec.yaml:

dependencies:
  sharemap_maplib_flutter: ^0.0.1

Or run:

flutter pub add sharemap_maplib_flutter

Usage

Here is a simple example showing how to initialize and use the ShareMapLibre widget:

import 'package:flutter/material.dart';
import 'package:sharemap_maplib_flutter/sharemap_maplib_flutter.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('ShareMap MapLibre Demo')),
        body: const ShareMapLibre(
          xApiKey: "YOUR_API_KEY",
          secretKey: "YOUR_SECRET_KEY",
          mode: ShareMapMode.prod,
          mapStyle: ShareMapStyle.sharemap,
          initialCameraPosition: CameraPosition(
            target: LatLng(10.2312, 107.0134),
            zoom: 11.0,
          ),
          layerCodes: [
            'vn-industrial-zones',
          ],
        ),
      ),
    );
  }
}

Additional information

For more details on customizable options (e.g., customize theme colors, dynamic layer management, custom style assets), refer to the documentation or contact the ShareMap Live team at sharemap.live.