Skip to content

Fixed Scale for Markers (feature) #52

@alfanhui

Description

@alfanhui

Hey,

Would be great to see a fixed scale for markers, to cover a consistent area between zooms.

I did try to implement a solution in the marker_layer.dart, togglable by a new variable fixedScale, but unable to adjust size bigger than 100x100.

Ideas:
map.getZoomScale(map.zoom, map.zoom) always returns 1.0 given the duplicated arguments, so currently its not doing anything in current code. I think it was placed here for this particular feature in the future. I believe the starting zoom should populate the second argument to maintain the starting size of the widget(image).

Current Implementation:
My current implementation looks something like this (considering my starting zoom is 17.0).
Screen capture on youtube
Trouble I found is that the marker Width and Height have to be within 0-100 to work. My marker's widget is a AssetImage in a container.

Widget build(BuildContext context) {
[...]
          var width = markerOpt.width;
          var height = markerOpt.height;

          var pixelPosX =
              (pos.x - (markerOpt.width - markerOpt._anchor.left)).toDouble();
          var pixelPosY =
              (pos.y - (markerOpt.height - markerOpt._anchor.top)).toDouble();

          if (markerOpt.fixScale) {
            width = markerOpt.width * map.getZoomScale(map.zoom, 17.0);
            height = markerOpt.height * map.getZoomScale(map.zoom, 17.0);

            pixelPosX = (pos.x -
                    (width -
                        (markerOpt._anchor.left *
                            map.getZoomScale(map.zoom, 17.0))))
                .toDouble();
            pixelPosY = (pos.y -
                    (height -
                        (markerOpt._anchor.top *
                            map.getZoomScale(map.zoom, 17.0))))
                .toDouble();
          }

          if (!latlngBounds.contains(markerOpt.point)) {
            continue;
          }

          markers.add(
            new Positioned(
              width: width,
              height: height,
              left: pixelPosX,
              top: pixelPosY,
              child: markerOpt.builder(context),
            ),
          );
        }
[...]

Got any ideas on how to increase the size?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions