google_static_maps_controller 0.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

google_static_maps_controller #

Codemagic build status

The package provides simple access to the Google Static Maps service.

Getting Started #

StaticMap widget: #

// ***

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        /// Declare your static map
        child: StaticMap(
          width: 400,
          height: 400,
          scaleToDevicePixelRatio: true,
          googleApiKey: "<GOOGLE_API_KEY>",
          /// Declare optional markers
          markers: <Marker>[
            /// Define marker style
            Marker(
              color: Colors.lightBlue,
              label: "A",
              locations: [
                /// Provide locations for markers of a defined style
                Location(-3.1178833, -60.0029284),
                Location(-3.1467579, -59.8753814),
              ],
            ),
            /// Define another marker style with custom icon
            Marker.custom(
              anchor: MarkerAnchor.bottom,
              icon: "https://goo.gl/1oTJ9Y",
              locations: [
                Location(-3.1694166, -60.1041517),
              ],
            )
          ],
        ),
      ),
    );
  }

// ***

StaticMapController #

  Widget build(BuildContext context) {
    /// Declare static map controller
     const _controller = StaticMapController(
      googleApiKey: "<GOOGLE_API_KEY>",
      width: 400,
      height: 400,
      zoom: 10,
      center: Location(-3.1178833, -60.0029284),
    );

    /// Get URL of the declared static map
    String mapImageUrl = _controller.url.toString();

    return Scaffold(
      body: Center(
        /// Display as a normal network image
        child: Image.network(
          mapImageUrl,
        ),
      ),
    );
  }
FeatureStatus
Base Static map support
Zoom levels
Image sizes
Map types
Markers
Map styles
Paths
Encoded Polylines
Viewports

✅ - done
🧪 - experimental
⚙️ - work in progress
❌ - not yet implemented

Example: #

map_screenshot

[0.3.0] - 17.03.2020 #

  • Added styles for maps

[0.2.0] - 17.03.2020 #

  • Added Marker.custom constructor that allows using custom marker icons

[0.1.0] - 13.03.2020 #

  • Improve readme

[0.0.1] - 13.03.2020 #

  • Initial release

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Google static map demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StaticMap(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        scaleToDevicePixelRatio: true,
        googleApiKey: "<GOOGLE-API-KEY>",
        styles: <MapStyle>[
          MapStyle(
            element: StyleElement.geometry.fill,
            feature: StyleFeature.landscape.natural,
            rules: <StyleRule>[
              StyleRule.hue(Colors.blue),
              StyleRule.lightness(-10),
            ],
          )
        ],
        markers: <Marker>[
          Marker(
            color: Colors.lightBlue,
            label: "A",
            locations: [
              Location(-3.1178833, -60.0029284),
              Location(-3.1467579, -59.8753814),
            ],
          ),
          Marker.custom(
            anchor: MarkerAnchor.bottom,
            icon: "https://goo.gl/1oTJ9Y",
            locations: [
              Location(-3.1694166, -60.1041517),
            ],
          )
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  google_static_maps_controller: ^0.3.0

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:google_static_maps_controller/google_static_maps_controller.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
66
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Jul 9, 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 not compatible with SDK dart

Because:

  • google_static_maps_controller that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.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