Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Djakh opened this issue Jul 11, 2024 · 11 comments

Comments

@Djakh
Copy link

Djakh commented Jul 11, 2024

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.

@liodali
Copy link
Owner

liodali commented Jul 11, 2024

can you shows us example to identify the issue

@Djakh
Copy link
Author

Djakh commented Jul 11, 2024

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
Copy link
Author

Djakh commented Jul 11, 2024

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

@liodali
Copy link
Owner

liodali commented Jul 11, 2024

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

@Djakh
Copy link
Author

Djakh commented Jul 12, 2024

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.

@liodali
Copy link
Owner

liodali commented Jul 12, 2024

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

@Djakh
Copy link
Author

Djakh commented Jul 15, 2024

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?

@liodali
Copy link
Owner

liodali commented Jul 15, 2024

better use staticPoints
i will give you example later on sorry

@Djakh
Copy link
Author

Djakh commented Jul 15, 2024

it is okey, take your time.

@Djakh
Copy link
Author

Djakh commented Jul 15, 2024

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

@liodali
Copy link
Owner

liodali commented Jul 16, 2024

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",
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants