ibrierley / flutter_map_dragmarker

A drag marker for flutter_map
BSD 3-Clause "New" or "Revised" License
54 stars 37 forks source link

Add children widget support #9

Closed jiazeh closed 2 years ago

jiazeh commented 2 years ago

Thanks to the author’s contribution, support for flutter_map's Children Widgets is added here

FlutterMap(
  options: MapOptions(
    allowPanningOnScrollingParent: false, /// IMPORTANT for dragging
    center: LatLng(45.5231, -122.6765),
    zoom: 6.4,
  ),
  children: [
    TileLayerWidget(
      options: TileLayerOptions(
        urlTemplate:
            'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
        subdomains: ['a', 'b', 'c'],
        maxZoom: 19,
      ),
    ),
    DragMarkerPluginWidget(
      options: DragMarkerPluginOptions(
        markers: [
          DragMarker(
            point: LatLng(45.2131, -122.6765),
            width: 80.0,
            height: 80.0,
            offset: const Offset(0.0, -8.0),
            builder: (ctx) {
              return const Icon(Icons.location_on, size: 50);
            },
            onDragStart: (details, point) =>
                debugPrint("Start point $point"),
            onDragEnd: (details, point) =>
                debugPrint("End point $point"),
            onDragUpdate: (details, point) {},
            onTap: (point) {
              debugPrint("on tap");
            },
            onLongPress: (point) {
              debugPrint("on long press");
            },
            feedbackBuilder: (ctx) {
              return const Icon(Icons.edit_location, size: 75);
            },
            feedbackOffset: const Offset(0.0, -18.0),
            updateMapNearEdge: true,
            nearEdgeRatio: 2.0,
            nearEdgeSpeed: 1.0,
          ),
          DragMarker(
            point: LatLng(45.535, -122.675),
            width: 80.0,
            height: 80.0,
            builder: (ctx) {
              return const Icon(Icons.location_on, size: 50);
            },
            onDragEnd: (details, point) {
              debugPrint('Finished Drag $details $point');
            },
            updateMapNearEdge: false,
          )
        ],
      ),
    )
  ],
),

see more: https://github.com/jiazeh/flutter_map_dragmarker

jiazeh commented 2 years ago

It work!