flutter_map_dragmarker 4.0.2 copy "flutter_map_dragmarker: ^4.0.2" to clipboard
flutter_map_dragmarker: ^4.0.2 copied to clipboard

outdated

Dragmarker class for flutter_map

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_dragmarker/dragmarker.dart';

void main() {
  runApp(TestApp());
}

class TestApp extends StatefulWidget {
  @override
  _TestAppState createState() => _TestAppState();
}

class _TestAppState extends State<TestApp> {
  @override
  void initState() {
    super.initState();
  }

  LatLng _marker1Position = LatLng(44.1461, 9.6400);
  LatLng _marker2Position = LatLng(44.1461, 9.6412);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: FlutterMap(
            options: MapOptions(
              absorbPanEventsOnScrollables: false,
              center: _marker1Position,
              zoom: 18,
            ),
            children: [
              TileLayer(
                  urlTemplate:
                  'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
                  subdomains: ['a', 'b', 'c']),
              DragMarkers(
                markers: [
                  DragMarker(
                    point: LatLng(44.1461, 9.6400),
                    width: 80.0,
                    height: 80.0,
                    offset: const Offset(0.0, -8.0),
                    builder: (ctx) => const Icon(Icons.location_on, size: 50),
                    onDragStart: (details, point) =>
                        print("Start point $point"),
                    onDragEnd: (details, point) => print("End point $point"),
                    onDragUpdate: (details, point) {setState(() {
                      print("updating...");
                      _marker1Position = point;
                    });},
                    onTap: (point) {
                      print("on tap");
                    },
                    onLongPress: (point) {
                      print("EXon long press");
                    },
                    feedbackBuilder: (ctx) =>
                    const Icon(Icons.edit_location, size: 75),
                    feedbackOffset: const Offset(0.0, -18.0),
                    updateMapNearEdge: true,
                    nearEdgeRatio: 2.0,
                    nearEdgeSpeed: 1.0,
                  ),
                  DragMarker(
                    point: _marker2Position,
                    width: 80.0,
                    height: 80.0,
                    builder: (ctx) => const Icon(Icons.location_on, size: 50),
                    onDragEnd: (details, point) {
                      print('EXFinished Drag $details $point');
                    },
                    onDragUpdate: (details, point) {setState(() {
                      _marker2Position = point;
                    });},
                    updateMapNearEdge: false,
                  )
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
27
likes
0
pub points
94%
popularity

Publisher

unverified uploader

Dragmarker class for flutter_map

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_map, latlong2

More

Packages that depend on flutter_map_dragmarker