woosmap_flutter 1.2.4 copy "woosmap_flutter: ^1.2.4" to clipboard
woosmap_flutter: ^1.2.4 copied to clipboard

You can utilize this plugin API to directly embed interactive outdoor and indoor maps into your application. Additionally, you can incorporate store overlays to the map to highlight points of interest [...]

example/lib/main.dart

import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:woosmap_flutter/woosmap_flutter.dart';
import 'constants.dart';
import 'Screens/snippet_list.dart';

void main() {
  runApp(const AppConstants(
    child: MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  static const String _title = 'Code Sample';
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: _title,
      home: ListWoosmapPluginSample(),
    );
  }
}

class ExampleSnippet extends StatefulWidget {
  const ExampleSnippet({super.key});

  @override
  State<ExampleSnippet> createState() => _ExampleSnippetState();
}

class _ExampleSnippetState extends State<ExampleSnippet> {
  WoosmapController? _controller;
  TextEditingController? txtLogController;
  @override
  void initState() {
    super.initState();
    txtLogController = TextEditingController();
    if (_controller != null) {
      debugPrint("info ===> Indoor controller not initialize");
    }
  }

  @override
  void dispose() {
    txtLogController?.dispose();
    super.dispose();
  }

  Future<void> reloadMenu() async {
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Woosmap app (Events)'),
        actions: <Widget>[
          ExampleMenu(webViewController: _controller),
        ],
      ),
      body: SafeArea(
        child: Column(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Expanded(
                child: Align(
                    alignment: const AlignmentDirectional(-1, -1),
                    child: WoosmapMapViewWidget(
                      wooskey: Platform.isAndroid
                          ? AppConstants.of(context)?.privateKeyAndroid ?? ""
                          : AppConstants.of(context)?.privateKeyiOS ?? "",
                      onRef: (p0) async {
                        _controller = p0;
                        reloadMenu();
                      },
                      mapOptions: const {
                        "center": {"lat": 19.115932, "lng": 72.907852},
                        "zoom": 10
                      },
                      click: (message) {
                        txtLogController?.text =
                            "Click, ${txtLogController?.text}";
                      },
                      bounds_changed: () {
                        txtLogController?.text =
                            "bounds_changed, ${txtLogController?.text}";
                      },
                      center_changed: () {
                        txtLogController?.text =
                            "center_changed, ${txtLogController?.text}";
                      },
                      dblclick: (m) {
                        txtLogController?.text =
                            "dblclick, ${txtLogController?.text}";
                      },
                      drag: () {
                        txtLogController?.text =
                            "drag, ${txtLogController?.text}";
                      },
                      dragend: () {
                        txtLogController?.text =
                            "dragend, ${txtLogController?.text}";
                      },
                      dragstart: () {
                        txtLogController?.text =
                            "dragstart, ${txtLogController?.text}";
                      },
                      idle: () {
                        debugPrint("idle");
                        /*txtLogController?.text =
                            "idle, ${txtLogController?.text}";*/
                      },
                      mousemove: (x) {
                        txtLogController?.text =
                            "mousemove, ${txtLogController?.text}";
                      },
                      mouseout: (x) {
                        txtLogController?.text =
                            "mouseout, ${txtLogController?.text}";
                      },
                      mouseover: (x) {
                        txtLogController?.text =
                            "mouseover, ${txtLogController?.text}";
                      },
                      rightclick: (x) {
                        txtLogController?.text =
                            "rightclick, ${txtLogController?.text}";
                      },
                      zoom_changed: () {
                        txtLogController?.text =
                            "zoom_changed, ${txtLogController?.text}";
                      },
                    ))),
            Container(
                width: 100,
                height: 100,
                decoration: const BoxDecoration(
                  color: Color(0xFFDEE6E6),
                ),
                child: Column(mainAxisSize: MainAxisSize.max, children: [
                  Expanded(
                      child: Padding(
                    padding: const EdgeInsetsDirectional.fromSTEB(10, 5, 10, 5),
                    child: TextFormField(
                      controller: txtLogController,
                      minLines: null,
                      maxLines: null,
                      autofocus: true,
                      enabled: false,
                      obscureText: false,
                      decoration: const InputDecoration(
                        labelText: 'Events Log\n',
                        hintText: 'Event fired',
                        enabledBorder: UnderlineInputBorder(
                          borderSide: BorderSide(
                            color: Color(0x00000000),
                            width: 1,
                          ),
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(4.0),
                            topRight: Radius.circular(4.0),
                          ),
                        ),
                        focusedBorder: UnderlineInputBorder(
                          borderSide: BorderSide(
                            color: Color(0x00000000),
                            width: 1,
                          ),
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(4.0),
                            topRight: Radius.circular(4.0),
                          ),
                        ),
                        errorBorder: UnderlineInputBorder(
                          borderSide: BorderSide(
                            color: Color(0x00000000),
                            width: 1,
                          ),
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(4.0),
                            topRight: Radius.circular(4.0),
                          ),
                        ),
                        focusedErrorBorder: UnderlineInputBorder(
                          borderSide: BorderSide(
                            color: Color(0x00000000),
                            width: 1,
                          ),
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(4.0),
                            topRight: Radius.circular(4.0),
                          ),
                        ),
                      ),
                    ),
                  ))
                ]))
          ],
        ),
      ),
    );
  }
}

enum ExampleMenuOptions {
  fitBounds,
  getBounds,
  getCenter,
  getHeading,
  getTilt,
  getZoom,
  panBy,
  panTo,
  panToBounds,
  setCenter,
  setHeading,
  setTilt,
  setZoom,
}

class ExampleMenu extends StatelessWidget {
  const ExampleMenu({
    super.key,
    required this.webViewController,
  });

  final WoosmapController? webViewController;

  @override
  Widget build(BuildContext context) {
    return PopupMenuButton<ExampleMenuOptions>(
      key: const ValueKey<String>('ShowPopupMenu'),
      onSelected: (ExampleMenuOptions value) {
        switch (value) {
          case ExampleMenuOptions.fitBounds:
            _onFitBounds();
            break;
          case ExampleMenuOptions.getBounds:
            _onGetBounds().then((value) {
              if (value != null) {
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(jsonEncode(value.toJson()))),
                );
              }
            });
            break;
          case ExampleMenuOptions.getCenter:
            _onGetCenter().then((value) {
              if (value != null) {
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(jsonEncode(value.toJson()))),
                );
              }
            });
            break;
          case ExampleMenuOptions.getHeading:
            _onHeading().then((value) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text(jsonEncode(value))),
              );
            });
            break;
          case ExampleMenuOptions.getTilt:
            _onTilt().then((value) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text(jsonEncode(value))),
              );
            });
            break;
          case ExampleMenuOptions.getZoom:
            _onZoom().then((value) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('Zoom ${jsonEncode(value)}')),
              );
            });
            break;
          case ExampleMenuOptions.panBy:
            _onPanBy();
            break;
          case ExampleMenuOptions.panTo:
            _onPanTo();
            break;
          case ExampleMenuOptions.panToBounds:
            _onPanToBounds();
            break;
          case ExampleMenuOptions.setCenter:
            _onSetCenter();
            break;
          case ExampleMenuOptions.setHeading:
            _onSetHeading();
            break;
          case ExampleMenuOptions.setTilt:
            _onSetTilt();
            break;
          case ExampleMenuOptions.setZoom:
            _onSetZoom();
            break;
        }
      },
      itemBuilder: (BuildContext context) =>
          <PopupMenuItem<ExampleMenuOptions>>[
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.fitBounds,
          child: Text('fitBounds'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.getBounds,
          child: Text('getBounds'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.getCenter,
          child: Text('getCenter'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.getHeading,
          child: Text('getHeading'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.getTilt,
          child: Text('getTilt'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.getZoom,
          child: Text('getZoom'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.panBy,
          child: Text('panBy'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.panTo,
          child: Text('panTo'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.panToBounds,
          child: Text('panToBounds'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.setCenter,
          child: Text('setCenter'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.setHeading,
          child: Text('setHeading'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.setTilt,
          child: Text('setTilt'),
        ),
        const PopupMenuItem<ExampleMenuOptions>(
          value: ExampleMenuOptions.setZoom,
          child: Text('setZoom'),
        ),
      ],
    );
  }

  Future<void> _onFitBounds() async {
    await webViewController?.fitBounds(
        LatLngBounds.fromJson({
          "ne": {"lat": 48.844437932920535, "lng": 2.3743880269761393},
          "sw": {"lat": 48.854437932920535, "lng": 2.3843880269761393}
        }),
        WoosPadding.fromJson({"top": 2, "left": 2, "right": 3, "bottom": 3}));
    return;
  }

  Future<LatLng?> _onGetCenter() async {
    LatLng? result;
    result = await webViewController?.getCenter();
    return result;
  }

  Future<LatLngBounds?> _onGetBounds() async {
    LatLngBounds? result;
    result = await webViewController?.getBounds(
        WoosPadding.fromJson({"top": 2, "left": 2, "right": 3, "bottom": 3}));
    return result;
  }

  Future<double> _onHeading() async {
    double result;
    result = (await webViewController?.getHeading()) as double;
    return result;
  }

  Future<double> _onTilt() async {
    double result;
    result = (await webViewController?.getTilt()) as double;
    return result;
  }

  Future<double> _onZoom() async {
    double result;
    result = (await webViewController?.getZoom()) as double;
    return result;
  }

  Future<void> _onPanBy() async {
    await webViewController?.panBy(20, 10);
    return;
  }

  Future<void> _onPanTo() async {
    await webViewController?.panTo(
        LatLng.fromJson({"lat": 48.844437932920535, "lng": 2.3743880269761393}),
        WoosPadding.fromJson({"top": 2, "left": 2, "right": 3, "bottom": 3}));
    return;
  }

  Future<void> _onPanToBounds() async {
    await webViewController?.panToBounds(
        LatLngBounds.fromJson({
          "ne": {"lat": 48.844437932920535, "lng": 2.3743880269761393},
          "sw": {"lat": 48.854437932920535, "lng": 2.3843880269761393}
        }),
        WoosPadding.fromJson({"top": 2, "left": 2, "right": 3, "bottom": 3}));
    return;
  }

  Future<void> _onSetCenter() async {
    await webViewController?.setCenter(
        LatLng.fromJson({"lat": 48.844437932920535, "lng": 2.3743880269761393}),
        WoosPadding.fromJson({"top": 2, "left": 2, "right": 3, "bottom": 3}));
    return;
  }

  Future<void> _onSetHeading() async {
    await webViewController?.setHeading(20);
    return;
  }

  Future<void> _onSetTilt() async {
    await webViewController?.setTilt(5);
    return;
  }

  Future<void> _onSetZoom() async {
    await webViewController?.setZoom(20);
    return;
  }
}
7
likes
0
pub points
70%
popularity

Publisher

verified publisherwoosmap.com

You can utilize this plugin API to directly embed interactive outdoor and indoor maps into your application. Additionally, you can incorporate store overlays to the map to highlight points of interest and access relevant information.

Homepage

License

unknown (license)

Dependencies

flutter, http, plugin_platform_interface, webview_flutter, webview_flutter_android, webview_flutter_wkwebview

More

Packages that depend on woosmap_flutter