mapwize 0.0.1-beta.4

  • Readme
  • Changelog
  • Example
  • Installing
  • new59

Mapwize for Flutter #

Please note that this project is community driven and is not an official Mapwize product. We welcome feedback and contributions.

This Flutter plugin allows to show Mapwize indoor maps inside a Flutter widget. This project only supports a subset of the API exposed by the Mapwize native librairies.

Running the example app #

  • Install Flutter and validate its installation with flutter doctor
  • Clone the repository with git clone git@github.com:Mapwize/mapwize-sdk-flutter.git
  • Connect a mobile device or start an emulator, simulator or chrome
  • Locate the id of a the device with flutter devices
  • Run the app with cd Mapwize/example && flutter packages get && flutter run -d {device_id}

Adding a Mapwize Api key #

This project uses Mapwize data which requires a Mapwize account and a Mapwize api key. Obtain a Mapwize api key on Mapwize Studio.

To provide your api key, use the MapwizeMap constructor's apiKey parameter.

Using the SDK in your project #

This project is available on pub.dev. Follow the instructions to integrate a package into your flutter application. For platform specific integration, use the flutter application under the example folder as reference.

Map constructor parameters #

The following parameters can be passed to the MapwizeMap constructor.

apiKey #

Must be provided to display the content;

centerOnPlaceId #

If set, center on the place at start.

centerOnVenueId #

If set, center on the venue at start.

void onMapCreatedCallback(MapwizeMapController controller) #

Called when the widget has been added to the application.

void onMapLoadedCallback() #

Called when the map is fully loaded and ready to use. Method calls before this are not guarented to work.

void onMapClickCallback(LatLngFloor latLngFloor) #

Called when the user clicks on the map.

void onFloorsChangeCallback:(List<Floor> floors) #

Called when the available floors have changed.

void onFloorChangeCallback(Floor floor), #

Called when the displayed floor has changed.

void onVenueEnterCallback(Venue venue), #

Called when the displayed floor has changed.

Available methods #

Future<void> setFloor(double floor) #

Set the currently displayed floor.

Future<void> addImage(String name, Uint8List bytes, [bool sdf = false]) #

Add an image to the available images on the Mapbox map. Available images can be then used to display markers on the map.

Future<Symbol> addSymbol(SymbolOptions options, [Map data]) #

Add a Symbol to the map using SymbolOptions. You can add custom properties using the data map.

Future<List<Symbol>> addSymbols(List<SymbolOptions> options, [List<Map> data]) #

Add multples Symbol to the map using a List of SymbolOptions. You can add custom properties using the data map.

Future<LatLng> getSymbolLatLng(Symbol symbol) #

Retrieve the coordinates of a given Symbol.

Future<void> removeSymbol(Symbol symbol) #

Remove the given Symbol.

Future<void> removeSymbols(Iterable<Symbol> symbols) #

Remove all the given Symbols.

Future<void> clearSymbols() #

Remove all the Symbols.

Future<Line> addLine(LineOptions options, [Map data]) #

Add a Line to the map using LymbolOptions. You can add custom properties using the data map.

Future<List<LatLng>> getLineLatLngs(Line line) #

Retrieve the coordinates of a given Line.

Future<void> removeLine(Line line) #

Remove the given Line.

Future<void> clearLines() #

Remove all the Lines.

Contributing #

We welcome contributions to this repository! If you're interested in helping build this Mapwize/Flutter integration, please read the contribution guide to learn how to get started.

0.0.1-beta.4 #

  • Adding onVenueEnterCallback
  • Adding first implementation of Place and Venue objects
  • Adding setFloor method

0.0.1-beta.3 #

  • Fixing README.md format issue

0.0.1-beta.2 #

  • Updating README.md

0.0.1-beta.1 #

  • Adding basic constructor options
  • Adding basic callback methods
  • Adding basic methods

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:mapwize/mapwize.dart';

import 'dart:typed_data';

void main() => runApp(MaterialApp(home: MapViewExample()));

class MapViewExample extends StatelessWidget {

  MapwizeMapController controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: const Text('Flutter Mapwize Example')),
        body: Column(children: [
          Expanded(
              flex: 3,
              child: MapwizeMap(
                apiKey: "MapwizeDevAPIKEY", //This is a demo API KEY that CANNOT be used for production.
                centerOnVenueId: "56b20714c3fa800b00d8f0b5",
                onMapCreatedCallback: _onMapViewCreated,
                onMapLoadedCallback: _onMapLoaded,
                onMapClickCallback: _onMapClick,
                onFloorsChangeCallback: _onFloorsChanged,
                onFloorChangeCallback: _onFloorChanged,
                onVenueEnterCallback: _onVenueEnter,
              )
          ),
          new FlatButton(
            onPressed: _addLineAndMarker,
            child: new Icon(Icons.add),
          ),
          new FlatButton(
              onPressed: _removeLineAndMarker,
              child: new Icon(Icons.delete),
          ),
        ]));
  }

  /// Adds an asset image to the currently displayed style
  Future<void> addImageFromAsset(String name, String assetName) async {
    final ByteData bytes = await rootBundle.load(assetName);
    final Uint8List list = bytes.buffer.asUint8List();
    return controller.addImage(name, list);
  }

  void _addLineAndMarker() async {
    controller.setFloor(3);
    SymbolOptions options = SymbolOptions(
      geometry: LatLng(10.0, 10.0),
      iconImage: "assetImage",
      iconSize: 3
    );
    Symbol s = await this.controller.addSymbol(options);
    LineOptions lineOptions = LineOptions(
      geometry: <LatLng>[LatLng(0.0, 0.0), LatLng(10.0, 10.0)],
      lineColor: "#C51586"
    );
    debugPrint("$lineOptions");
    this.controller.addLine(lineOptions);
  }

  void _removeLineAndMarker() async {
    this.controller.clearSymbols();
    this.controller.clearLines();
  }

  void _onMapViewCreated(MapwizeMapController controller) {
    debugPrint("On map view created");
    this.controller = controller;
  }

  void _onMapLoaded() {
    debugPrint("On map loaded");
    addImageFromAsset("assetImage", "assets/custom-icon.png");
  }

  void _onMapClick(LatLngFloor llf) {
    debugPrint("On map click $llf");
  }

  void _onFloorsChanged(List<Floor> floors) {
    debugPrint("On floors changed $floors");
  }

  void _onFloorChanged(Floor floor) {
    debugPrint("On floor changed $floor");
  }

  void _onVenueEnter(Venue venue) {
    debugPrint("on venue enter ${venue.name}");
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mapwize: ^0.0.1-beta.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mapwize/mapwize.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:mapwize/mapwize.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:mapwize/mapwize.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:mapwize/mapwize.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:mapwize/mapwize.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • mapwize that is a package requiring null.

Health suggestions

Fix lib/src/interface/method_channel_mapwize.dart. (-1 points)

Analysis of lib/src/interface/method_channel_mapwize.dart reported 2 hints:

line 3 col 1: Prefer using /// for doc comments.

line 168 col 16: The method doesn't override an inherited method.

Fix lib/mapwize.dart. (-0.50 points)

Analysis of lib/mapwize.dart reported 1 hint:

line 4 col 8: Unused import: 'dart:math'.

Fix lib/src/implementation/models.dart. (-0.50 points)

Analysis of lib/src/implementation/models.dart reported 1 hint:

line 164 col 30: Avoid using braces in interpolation when not needed.

Fix additional 6 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/src/interface/mapwize_platform_interface.dart (1 hint)
  • lib/src/implementation/controller.dart (Run flutter format to format lib/src/implementation/controller.dart.)
  • lib/src/implementation/map.dart (Run flutter format to format lib/src/implementation/map.dart.)
  • lib/src/interface/callback.dart (Run flutter format to format lib/src/interface/callback.dart.)
  • lib/src/interface/line.dart (Run flutter format to format lib/src/interface/line.dart.)
  • lib/src/interface/symbol.dart (Run flutter format to format lib/src/interface/symbol.dart.)

Maintenance suggestions

The package description is too short. (-15 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test