Giter Club home page Giter Club logo

flutter_map_supercluster's People

Contributors

rorystephenson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_map_supercluster's Issues

Marker looses PopUp-Style when splayed clusters are collapsed

Hi,

thanks a lot for your work here - your project is really amazing and helpful.

During the customization inside of my project I realized that the PopUp-style of a Marker is removed as soon as the splayed clusters will be collapsed (by zooming out or manually collapsing them). In my case it would be great if the style could be maintained so that the user can find the selected Marker again. Is there a chance to avoid collapsing when a Marker is in PopUp-mode or maintain it´s style even if it is collapsed? I have investigated your code but didn´t found an easy way to manipulate it. Maybe I am overseeing something?

BTW, I am using the mutable SuperClusterLayer.

Cheers

Disable splaying

I'm migrating from version 2.3.0 to the latest version, 5.0.0-dev1 and I'm facing issues from changes made in version 3.

I've previously implemented my own UI for lots of markers placed exactly onto each other. I'd like to keep that, but the ClusterSplayDelegate seems required by SuperclusterLayer and I couldn't find a way to disable it or force it to display just the underlying markers without interfering with the marker tap function.

Am I missing something?

FM v6 is coming soon

The next version of flutter_map is coming soon, with breaking changes for all users and plugins!

Expected CHANGELOG: https://github.com/fleaflet/flutter_map/blob/release-prep/CHANGELOG.md
Likely to be merged PR with significant impacts: fleaflet/flutter_map#1615
Release prep PR: fleaflet/flutter_map#1632
New documentation (path liable to change): https://docs.fleaflet.dev/v/v6-1
Expected migration instructions, suitable for most users: https://docs.fleaflet.dev/v/v6-1/getting-started/migrating-to-v6
List of commits since v5 (more to come): fleaflet/flutter_map@v5.0.0...master

Can't use along flutter_map ^4.0.0

Hey mate, thanks for this package and your popup package! Im trying to upgrade to flutter map 4.0.0 along with your popup package 4.1.0 but im getting an issue with this package now:

Running "flutter pub get" in fsd_desktop...
Resolving dependencies...
Because flutter_map_supercluster >=2.2.1 depends on flutter_map ^3.1.0 and fsd_desktop depends on flutter_map ^4.0.0, flutter_map_supercluster >=2.2.1 is forbidden.
So, because fsd_desktop depends on flutter_map_supercluster ^2.3.0, version solving failed.

computeSize option missing?

There are following lines in SuperclusterLayer:

/// Implement this function to extract extra data from Markers which can be
/// used in the [builder] and [computeSize].
final ClusterDataBase Function(Marker marker)? clusterDataExtractor;

But I can't find this computeSize thing anywhere.

As I understand it should allow computing clusterWidgetSize for each cluster instead of having constant one.

So could you please explain what computeSize is and how to use it?

Can we customise the clustering icons?

As the title says, can we customise the clustering icon? Even better would be to change the icon depending on the number of items in the cluster, as shown in this example:

Screenshot 2023-02-22 090754

How to disable map rotation

Hi,

I am using SuperclusterLayer.mutable

this is the complete widget code:

      width: MediaQuery.of(context).size.width * 0.8,
      height: MediaQuery.of(context).size.height * 0.7,
      child: FlutterMap(
        options: MapOptions(
          center: position,
          zoom: 6,
          maxZoom: 15,
          rotationThreshold: 0,
          rotation: 0,
          pinchMoveWinGestures: MultiFingerGesture.pinchMove,
          pinchZoomWinGestures: MultiFingerGesture.pinchZoom,
          rotationWinGestures: MultiFingerGesture.none,
        ),
        children: [
          TileLayer(
            urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
            keepBuffer: 5,
          ),
          SuperclusterLayer.mutable(
            initialMarkers: markers,
            indexBuilder: IndexBuilders.rootIsolate,
            builder: (context, position, markerCount, extraClusterData) => Container(
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20.0),
                color: Colors.blue,
              ),
              child: Center(
                child: Text(
                  markerCount.toString(),
                  style: const TextStyle(color: Colors.white),
                ),
              ),
            ),
          ),
        ],
      ),

But I can't turn off rotation when using the map from phone

How should I do it?

Best Regards

Customized cluster widgets

How do i make a customized cluster widgets that show a summary of their contained Markers as shown in your medium article?

Cannot modify markers

I can add and remove markers. But I cannot modify them. Modifications cannot be seen on the map.

I use a custom marker called HashedMarker with additional properties and overrides to handle equality. Even if I override equality of HashedMarker when I modify a marker only position matters. Status changes don't trigger a rebuild.

class HashedMarker extends Marker {
  final VoidCallback onTap;
  final CustomMarker child;
  final MarkerStatus status;

  HashedMarker({
    required super.point,
    required this.onTap,
    required this.child,
    required this.status,
    super.width = 80.0,
    super.height = 80.0,
    AnchorPos? anchorPos,
  }) : super(
          anchorPos: anchorPos ?? AnchorPos.align(AnchorAlign.top),
          builder: (context) => GestureDetector(
            onTap: onTap,
            child: child,
          ),
        );

  HashedMarker copyWith({
    VoidCallback? onTap,
    CustomMarker? child,
    MarkerStatus? status,
    LatLng? point,
    double? width,
    double? height,
    AnchorPos? anchorPos,
  }) {
    return HashedMarker(
      point: point ?? super.point,
      onTap: onTap ?? this.onTap,
      child: child ?? this.child,
      width: width ?? super.width,
      height: height ?? super.height,
      anchorPos: anchorPos ?? super.anchorPos,
      status: status ?? this.status,
    );
  }

  @override
  bool operator ==(Object other) {
    if (other is! HashedMarker) return false;
    return super.point == other.point && this.status == other.status;
  }

  @override
  int get hashCode =>Object.hash(super.point, status);
}

I have a custom marker controller that uses SuperclusterMutableController's methods internally. And currently our focus on modifyMarker(). Which I use like below:

class ClusterMarkerController {
  final SuperclusterMutableController _superclusterController;

  ClusterMarkerController()
      : _superclusterController = SuperclusterMutableController();

  static final List<HashedMarker> _hashedMarkersList = [];

  SuperclusterMutableController get controller => _superclusterController;

  void modifyMarker(HashedMarker newMarker) {
    final index = _hashedMarkersList
        .indexWhere((element) => element.point == newMarker.point);

    final oldMarker = _hashedMarkersList[index];

    _hashedMarkersList[index] = newMarker;

    _superclusterController.modifyMarker(oldMarker, newMarker);
  }
}

I give controller to SuperclusterLayer.mutable like below.

SuperclusterLayer.mutable(
      controller: widget.clusterController.controller,
      indexBuilder: IndexBuilders.computeWithCopiedMarkers,
      ...
)

Support user-defined behaviour when trying to open an un-openable cluster.

This was originally raised in another issue:

Hello @rorystephenson great work on this package, we love it!

With regards to markers that are too close to uncluster, we have a map where many markers may share the same coordinates, too many for splaying to make sense, and instead we were hoping to be able to override the splaying, and have a method that gives us the items of the cluster, which we may then use to open a listview in a modal. This would be more scalable and safe for an unknown and large amount of markers, contrary to the splaying which we believe could become troublesome for the user with too many markers. Is such a feature anything your package could support?

Failing to assign marker to initialMaker

When I try to assign markers to a list and giving it to initialMarkers (doesn't matter if as a layer or a list of Marker), it throws:

../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_map_supercluster-3.0.0+1/lib/src/layer/expanded_cluster_manager.dart:99:71: Error: The argument type 'int' can't be assigned to the parameter type 'LayerCluster<Marker>'.
 - 'LayerCluster' is from 'package:supercluster/src/layer_element.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.dev/supercluster-2.3.0/lib/src/layer_element.dart').
 - 'Marker' is from 'package:flutter_map/src/layer/marker_layer.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.dev/flutter_map-4.0.0/lib/src/layer/marker_layer.dart').
          .childrenOf((layerCluster as ImmutableLayerCluster<Marker>).id)

This is how I set FlutterMap:

FlutterMap(
          nonRotatedChildren: <Widget>[
            SuperclusterLayer.immutable(
              controller: _superclusterController,
              calculateAggregatedClusterData: true,
              clusterWidgetSize: const Size(40, 40),
              anchor: AnchorPos.align(AnchorAlign.center),
              initialMarkers: layer,
              builder: (BuildContext context, LatLng position, int markerCount,
                  ClusterDataBase? extraClusterData) {
                return Container(child: Text("culo"));
              },
            )
          ],
          mapController: _mapController,
          options: MapOptions(
            onMapReady: () {
              _mapController.mapEventStream.listen((evt) {});
              // And any other `MapController` dependent non-movement methods
            },
            center: LatLng(41.902, 12.5),
            zoom: 7,
          ),
          children: [
            //MarkerLayer(markers: markers,),
            TileLayer(
              urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
              userAgentPackageName: 'com.example.app',
            ),
          ],
        ),

And this how I add Markers to list:

  loadJson() async {
    final String response =
        await rootBundle.loadString('TREMESTIERI_ETNEO.json');
    final data = await json.decode(response);
    for (var civ in data) {
      print(civ);
      markers.add(
        Marker(
            point: LatLng(
                double.parse(civ['latitude']), double.parse(civ['longitude'])),
            width: 50,
            height: 50,
            builder: (context) =>  IconButton(
                onPressed: () {
                  print("culo");
                },
                icon: Icon(
                  Icons.circle,
                ))),
      );
    }
    layer = MarkerLayer(
      markers: markers,
    );
  }

Even copying the example in example/ gives the same error

Can`t open cluster

If I have several markers very close to each other, I can't zoom deeper to open cluster because map has some max zoom parameter.

Illegal argument in isolate message: Library:'dart:ui'

Hello,
I'm getting following error:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Illegal argument in isolate message: (object extends NativeWrapper - Library:'dart:ui' Class: EngineLayer)
#0      Isolate._spawnFunction (dart:isolate-patch/isolate_patch.dart:399:25)
#1      Isolate.spawn (dart:isolate-patch/isolate_patch.dart:379:7)
#2      Isolate.run (dart:isolate:238:15)
#3      compute (package:flutter/src/foundation/_isolates_io.dart:18:18)
#4      compute (package:flutter/src/foundation/isolates.dart:76:19)
#5      _SuperclusterLayerState._initializeClusterManager.<anonymous closure> (package:flutter_map_supercluster/src/layer/supercluster_layer.dart:339:15)
<asynchronous suspension>

What should I do?
Deps:

  cupertino_icons: ^1.0.2
  sliding_up_panel: ^2.0.0+1
  vector_map_tiles: ^3.1.4
  flutter_map: ^3.1.0
  latlong2: ^0.8.1
  geolocator: ^9.0.1
  flutter_map_location_marker: ^5.1.0+1
  flutter_svg: ^1.1.2
  http: ^0.13.5
  maps_launcher: ^2.0.1
  url_launcher: ^6.1.5
  flutter_map_dragmarker: ^4.1.2
  cross_fade: ^0.3.1
  connectivity_plus: ^3.0.2
  flutter_launcher_icons: ^0.11.0
  flutter_map_supercluster: ^2.2.0

Flutter version:

environment:
  sdk: '>=2.18.0-257.0.dev <3.0.0'

Info: flutter_map_marker_plugin

In the readme.md you suggest to check out flutter_map_marker_plugin for beautiful clustering animations, where can I find it?
thank you

Rotate

How to rotate cluster marker and it's child initialMarkers?

Reinstate maximum cluster zoom option

This originally added as a temporary solution for clusters that couldn't be opened because their un-clustering zoom was higher than the map's maximum zoom. Once cluster splaying was implemented I removed this option but it turns out some users want it for other valid reasons.

#12 Will resolve this, just waiting for flutter_map v6 to be released.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.