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

Fixed Scale for Markers (feature) #52

Closed
alfanhui opened this issue Jun 12, 2018 · 2 comments
Closed

Fixed Scale for Markers (feature) #52

alfanhui opened this issue Jun 12, 2018 · 2 comments

Comments

@alfanhui
Copy link
Contributor

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?

@avioli
Copy link
Contributor

avioli commented Jun 14, 2018

Do you mean fixed scale as in scale the markers up/down while the map scales? To me fixed scale means to keep them at a fixed scale, which is already the case.

Polygons scale with the map. You can look at them for ideas. They just use a painter, but the scaling logic is there.

Anyway the plugin system is there for this reason - make a plugin and @johnpryan could integrate it at some point into the core. This way the plugin system will get some love too. :)

@johnpryan
Copy link
Collaborator

as @avioli mentioned, It looks like you have a solution that can be implemented using the plugin api. I'm going to close but feel free to reopen if you feel that doesn't fit your needs.

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

3 participants