mapping_library 0.0.2

  • Readme
  • Changelog
  • Installing
  • new32

Basic Mapping engine for Flutter #

This library supplies a basic implementation of a tiled mapping engine for flutter. There is a basic openstreetmap widget available which can be set on a specific geographic location. Basic gestures are implemented to pan and zoom this map. More advanced options are available for adding markers and vector based object like lines and circles.

  • Version: 0.0.1

Disclaimer: This version is far from finished. Most of the options just supply very basic functionality which might still holds many bugs. We are continuesly adding and improving options. Use at your own risk

Installation #

dependencies:
     mapping_library: any

Examples #

Basic Example

Create an instance of the OsmMap object in the contructor of your App widget as the map needs to be in persistent memory. Add this instance to the Build function..

        
    import 'package:mapping_library/Widgets/OsmMap.dart';
    import 'package:mapping_library/utils/geopoint.dart';
    import 'package:mapping_library/utils/mapposition.dart';
        
    class MyApp extends StatelessWidget {
      MyApp() : super() {
        _osmMap = _createOsmMapWidget();
      }
        
        OsmMap _osmMap;
        
        Widget _createOsmMapWidget() {
            return OsmMap(
                mapPosition: new MapPosition.Create(
                  geoPoint: new GeoPoint(52.45657243868931, 5.52041338863477),
                  zoomLevel: 11,
                )
            );
        }
        
        @override  
        Widget build(BuildContext context) {  
            return MaterialApp(  
                title: 'Flutter Demo',  
                theme: ThemeData(  
                    primarySwatch: Colors.blue,  
                ),  
                home: Container(   
                    child: _osmMap,
                )  
            );  
        }
    }
        

There are three callback methods:

  • mapReady (Fired when the map initially is created, needed when you want to add more layers)
  • mapPositionChanged (Fired as soon as the position or zoom of the map is changed)
    Return: Viewport object, this holds both the current MapPosition as the visual BoundingBox of the current map
  • mapTabbed (Fired when you tab on the map)
    Return: GeoPoint object, this holds the geographic location of the position tabbed.

Advanced examples

If you want to do more advanced stuff you need to create all the objects in the contructor of the Widget like this:

Define a MapView variable, Create this new object in the apps constructor and add the mapReady event handler.


class MyApp extends StatelessWidget {
  MyApp() : super() {
    _mapView = new mapview.MapView(_mapReady);
  }

  // Define a Mapview
  mapview.MapView _mapView;

  _mapReady(mapview.MapView mapView) {
  }
  
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Container(
        child: _mapView
      )
    );
  }
}

Continue by adding code to the mapReady callback function. First create a base Layer. This normally should be a TileLayer. Define a http source where the tiles are served from, Create a new HttpTileSource and finally create a new TileLayer using this source.

_mapReady(mapview.MapView mapView) {
    final _url = "http://c.tile.openstreetmap.org/##Z##/##X##/##Y##.png";
    HttpTileSource osmTileSource = new HttpTileSource(_url); TileLayer
    tileLayer = new TileLayer(osmTileSource); _mapView.AddLayer(tileLayer);
    //
    //
    }

Create a new MapPosition to initially more and zoom the map to a chosen default location. Create a new GeoPoint with the chosen geographic location and use this with the desired zoomlevel to create a new MapPosition. Set the mapview to this new MapPosition.

GeoPoint s = new GeoPoint(52.45657243868931, 5.52041338863477);
MapPosition _initialPosition = MapPosition.fromGeopointScale(s, 11);
_mapView.SetMapPosition(_initialPosition);

[0.0.2] 3 Oktober 2019

  • Format changes
  • Added sample
  • Started on API Documentation

[0.0.1] 2 Oktober 2019

  • TODO: Describe initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  mapping_library: ^0.0.2

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:mapping_library/core/mapview.dart';
import 'package:mapping_library/core/mapviewgestures.dart';
import 'package:mapping_library/core/mapviewstatebase.dart';
import 'package:mapping_library/core/values.dart';
import 'package:mapping_library/core/viewport.dart';
import 'package:mapping_library/example/osm_example.dart';
import 'package:mapping_library/layers/layer.dart';
import 'package:mapping_library/layers/layerpainter.dart';
import 'package:mapping_library/layers/layers.dart';
import 'package:mapping_library/layers/markerslayer.dart';
import 'package:mapping_library/layers/Markers/defaultimagemarker.dart';
import 'package:mapping_library/layers/Markers/markerbase.dart';
import 'package:mapping_library/layers/Markers/markers.dart';
import 'package:mapping_library/layers/Markers/Renderers/defaultmarkerrenderer.dart';
import 'package:mapping_library/layers/Markers/Renderers/defaultmarkers.dart';
import 'package:mapping_library/layers/Markers/Renderers/markerrenderer.dart';
import 'package:mapping_library/layers/Markers/Renderers/simplemarkerrenderer.dart';
import 'package:mapping_library/layers/Markers/simplemarker.dart';
import 'package:mapping_library/layers/tilelayer.dart';
import 'package:mapping_library/layers/vectorlayer.dart';
import 'package:mapping_library/layers/Vector/circle.dart';
import 'package:mapping_library/layers/Vector/geombase.dart';
import 'package:mapping_library/layers/Vector/line.dart';
import 'package:mapping_library/layers/Vector/vectors.dart';
import 'package:mapping_library/tiles/httptilesource.dart';
import 'package:mapping_library/tiles/tile.dart';
import 'package:mapping_library/tiles/tileboundingbox.dart';
import 'package:mapping_library/tiles/tilesource.dart';
import 'package:mapping_library/utils/angles.dart';
import 'package:mapping_library/utils/boundingbox.dart';
import 'package:mapping_library/utils/fastmath.dart';
import 'package:mapping_library/utils/geopoint.dart';
import 'package:mapping_library/utils/mapposition.dart';
import 'package:mapping_library/utils/mercatorprojection.dart';
import 'package:mapping_library/Widgets/OsmMap.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
55
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
75
Overall:
Weighted score of the above. [more]
32
Learn more about scoring.

We analyzed this package on Oct 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/utils/mercatorprojection.dart. (-8.63 points)

Analysis of lib/utils/mercatorprojection.dart reported 18 hints, including:

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

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

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

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

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

Fix lib/layers/Markers/markerbase.dart. (-8.17 points)

Analysis of lib/layers/Markers/markerbase.dart reported 17 hints, including:

line 28 col 10: Name non-constant identifiers using lowerCamelCase.

line 31 col 7: Name non-constant identifiers using lowerCamelCase.

line 32 col 7: Name non-constant identifiers using lowerCamelCase.

line 39 col 7: Name non-constant identifiers using lowerCamelCase.

line 42 col 7: Name non-constant identifiers using lowerCamelCase.

Fix lib/core/values.dart. (-6.78 points)

Analysis of lib/core/values.dart reported 14 hints, including:

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

line 4 col 14: Name non-constant identifiers using lowerCamelCase.

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

line 8 col 14: Name non-constant identifiers using lowerCamelCase.

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

Fix additional 29 files with analysis or formatting issues. (-34.14 points)

Additional issues in the following files:

  • lib/core/viewport.dart (13 hints)
  • lib/tiles/tile.dart (8 hints)
  • lib/core/mapview.dart (6 hints)
  • lib/utils/geopoint.dart (5 hints)
  • lib/tiles/tileboundingbox.dart (4 hints)
  • lib/layers/Markers/defaultimagemarker.dart (3 hints)
  • lib/layers/layerpainter.dart (3 hints)
  • lib/layers/markerslayer.dart (3 hints)
  • lib/core/mapviewstatebase.dart (2 hints)
  • lib/layers/Markers/Renderers/markerrenderer.dart (2 hints)
  • lib/layers/Vector/line.dart (2 hints)
  • lib/tiles/tilesource.dart (2 hints)
  • lib/Widgets/OsmMap.dart (1 hint)
  • lib/example/osm_example.dart (1 hint)
  • lib/layers/Markers/Renderers/defaultmarkerrenderer.dart (1 hint)
  • lib/layers/Markers/Renderers/defaultmarkers.dart (1 hint)
  • lib/layers/Markers/Renderers/simplemarkerrenderer.dart (1 hint)
  • lib/layers/Markers/markers.dart (1 hint)
  • lib/layers/Markers/simplemarker.dart (1 hint)
  • lib/layers/Vector/circle.dart (1 hint)
  • lib/layers/Vector/geombase.dart (1 hint)
  • lib/layers/Vector/vectors.dart (1 hint)
  • lib/layers/layers.dart (1 hint)
  • lib/layers/tilelayer.dart (1 hint)
  • lib/layers/vectorlayer.dart (1 hint)
  • lib/tiles/httptilesource.dart (1 hint)
  • lib/utils/boundingbox.dart (1 hint)
  • lib/utils/mapposition.dart (1 hint)
  • lib/layers/layer.dart (Run flutter format to format lib/layers/layer.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and mapping_library.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

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.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
vector_math ^2.0.8 2.0.8
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
flutter_test