osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Markers | when adding markers with different icon types at the same time, markers take only one icon type

Open Djakh opened this issue 1 year ago • 16 comments

The first problem is that the controller can't add a list of icons, which is fine, but it creates chaos when adding markers with different icon types.

Djakh avatar Jul 11 '24 12:07 Djakh

can you shows us example to identify the issue

liodali avatar Jul 11 '24 12:07 liodali

yep here you go: void addDifferentIconTypeMarkers() { _mapController.addMarker( GeoPoint(latitude: 41.2995, longitude: 69.2401), markerIcon: const MarkerIcon(icon: Icon(Icons.car_crash)), );

_mapController.addMarker(
  GeoPoint(latitude: 61.5240, longitude: 105.3188),
  markerIcon: const MarkerIcon(icon: Icon(Icons.fire_truck)),
);
_mapController.addMarker(
  GeoPoint(latitude: 40.0974, longitude: 65.3525),
  markerIcon: const MarkerIcon(icon: Icon(Icons.mark_email_read)),
);

_mapController.addMarker(
  GeoPoint(latitude: 55.3781, longitude: 3.4360),
  markerIcon: const MarkerIcon(icon: Icon(Icons.fire_extinguisher)),
);

} initialize the map controller and just run it, you will see the problem

Djakh avatar Jul 11 '24 14:07 Djakh

i gave 4 different icons for 4 markers, but all markers will be created with the last icon which is fire_extinguisher

Djakh avatar Jul 11 '24 14:07 Djakh

you need to add await before addMarker because we render the icon and then we send them to map engine as drawable or image for ios side or web i will add api to add multiple markers

liodali avatar Jul 11 '24 14:07 liodali

yes, now I'm adding a wait, but I have an average of 800-1000 markers on the map, and waiting for each marker is very slow, it's time-consuming and inconvenient, so it would be great if there was an option to add all the markers at the same time with different types of icons , this will really improve performance.

Djakh avatar Jul 12 '24 04:07 Djakh

is those markers all of them has it own icon ? maybe you can show them by boundingbox if the markers is in bounds add it if not remove it

liodali avatar Jul 12 '24 18:07 liodali

there is only 4 type of icons, but about 200 markers have one type of icon, 300 markers another and so on, boundingbox it seems interesting thing, could you give simple example how can i use it in my case?

Djakh avatar Jul 15 '24 05:07 Djakh

better use staticPoints i will give you example later on sorry

liodali avatar Jul 15 '24 07:07 liodali

it is okey, take your time.

Djakh avatar Jul 15 '24 08:07 Djakh

I've been stuck with this problem for about a week, it's okay if I wait a little longer.

Djakh avatar Jul 15 '24 08:07 Djakh

you can use our mixin OSMMixinObserver and call onRegionChanged the use Region object that has BoundingBox and we have method called inBoundingBox i will add api in that to check list of geopoint and return only the points that are in boudingbox and as for now use staticPoints in OSMFlutter to define your group of markers like this


 staticPoints: [
          StaticPositionGeoPoint(
            "marker1",
            const MarkerIcon(
              icon: Icon(
               icon1,
                color: Colors.green,
                size: 32,
              ),
            ),
            [
             /// here put GeoPoint if already there
            ],
          ),
       StaticPositionGeoPoint(
            "marker2",
            const MarkerIcon(
              icon: Icon(
               icon2,
                color: Colors.green,
                size: 32,
              ),
            ),
            [
             /// here put GeoPoint if already there
            ],
          ),


Then use the mapController to set points as in the example below


 await controller.setStaticPosition(
      [
        //GeoPoint
      ],
      "marker1",
    );

liodali avatar Jul 16 '24 17:07 liodali

you can check latest version fix this issue

liodali avatar Jan 02 '25 09:01 liodali

@liodali v.1.3.6 the same result as provided in a head, if used func .addMarker('diffGeo','customImage') will use the last image for all. Only if will use synced placement does it work but if we talk about 10+ markers also with adding a Figure this takes a lot of time.

m.b. You can provide more details about the approach how it is possible

SamuseuMI avatar Feb 04 '25 02:02 SamuseuMI

i did not understand you still get the issue with addMarker or you have issue with staticPosition ?

liodali avatar Feb 04 '25 07:02 liodali

@liodali There was a problem with addMarker. Is static position the right approach?

SamuseuMI avatar Feb 04 '25 08:02 SamuseuMI

advice to use it, im.planning to improve to be more cluster markers staff

liodali avatar Feb 04 '25 08:02 liodali