flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[Question] How can I make panning boundaries for any zoom?

Open maxgmer opened this issue 8 years ago • 20 comments

I use MapBox map. When I pan far enough, I see white background and I don't want users to see it. The existing solution is to set LatLng for nw and se boundaries, but this approach is not valid, as it has to change according to current zoom. Is there any other solution? Thanks.

maxgmer avatar Nov 27 '18 08:11 maxgmer

Not sure if I'm being an idiot, but why shouldn't the LatLng corners work for any zoom ? (Trying to figure if it's a bug or something else).

ibrierley avatar Dec 05 '18 19:12 ibrierley

The way it works is it checks if the center of the screen is in boundaries. The rectangle of view can have different LatLng dimensions, which change when zoom changes. It would have worked perfectly if it checked corners for collision, not the center.

maxgmer avatar Dec 06 '18 05:12 maxgmer

Having the same issue. The boundaries seems to change depending on zoom level. As I zoom in, the boundary seems to get slightly smaller, which cuts off part of the map.

KaYBlitZ avatar Mar 12 '19 19:03 KaYBlitZ

Does anyone have a workaround for this?

OrKoN avatar May 07 '19 16:05 OrKoN

Selection_022

A screenshot to be clear about what issue I have.

OrKoN avatar May 07 '19 16:05 OrKoN

I tried to provide current bounds to isOutOfBounds but it looks like bounds are not quite correct.

OrKoN avatar May 07 '19 16:05 OrKoN

Selection_022

A screenshot to be clear about what issue I have.

Does anyone have a workaround for this?

q869939686 avatar Sep 24 '19 08:09 q869939686

Selection_022 A screenshot to be clear about what issue I have.

Does anyone have a workaround for this?

did you ever found a solution for this? Im also facing this problem.

roderikpeeters avatar Mar 05 '21 10:03 roderikpeeters

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 05 '21 02:04 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Apr 11 '21 02:04 github-actions[bot]

@roderikpeeters @q869939686 @OrKoN @KaYBlitZ @maxgmer I'm also facing this issue. Did anyone of you find a work-around?

This is still an issue, so please reopen!

andrekovac avatar May 30 '21 19:05 andrekovac

Needs re-open.

mchesnokov avatar Jun 28 '21 16:06 mchesnokov

Same issue!

I have figured if you somehow set up the right coordinates for swPanBoundary and nePanBoundary, the user can't go out from the map. But it is difficult to find the right one.

nemanjalugi avatar Nov 08 '21 12:11 nemanjalugi

What have you tried so far, and what are you trying to achieve ?

ibrierley avatar Aug 26 '22 17:08 ibrierley

Hi @aadi-github, that last comment didn't make any sense, it was just the stale message. Did you mean to write something else?

JaffaKetchup avatar Oct 12 '22 18:10 JaffaKetchup

Hi @aadi-github, that last comment didn't make any sense, it was just the stale message. Did you mean to write something else?

No, Actually the comment done by KaYBlitZ was actually the issue I was facing. The boundaries seems to change depending on the zoom level. As I zoom in, the boundary seems to get slightly smaller, which cuts off part of the map. ex: where you used to see the name of the river, suppose on zoom level 13; Now you won't be able to see that on zoom level 18. I think this is not just because of 'swPanBoundary' and 'nePanBoundary', it might be because zooming is related to the Coordinates of the 'center' also.

aadi-github avatar Oct 13 '22 08:10 aadi-github

I think we'd need to see an example, maybe some code with the 2 images at different zoom levels of the edges.

ibrierley avatar Oct 13 '22 09:10 ibrierley

I think we'd need to see an example, maybe some code with the 2 images at different zoom levels of the edges.

Ok, please look below example on zoom level 13, 14, 15. Screenshot_2022-10-14-19-14-11-845_me jpryan flutter_map_example Screenshot_2022-10-14-19-14-25-897_me jpryan flutter_map_example Screenshot_2022-10-14-19-14-53-163_me jpryan flutter_map_example

In above in level 13 you can observe NH10, but when going to 14 or 15 it shifts off the screen. I am not able to drag it down even if I had downloaded tiles of that coordinate. you will be able to see some of the part if you rotate the map but can't go anywhere near if(no draging or zooming) as the zoom level increases.

Below is the boundries and center coord :::

          FlutterMap(
            mapController: _mapController,
            options: MapOptions(
              zoom: _minZoom,
              minZoom: _minZoom,
              maxZoom: _maxZoom,
              center: LatLng(26.730925, 88.43126111),
              swPanBoundary: LatLng(26.70650, 88.41802),
              nePanBoundary: LatLng(26.72602, 88.44000),
            ),

I have tried maxBounds() instead of swPanBoundary and nePanBoundary which disables the every interaction to map. I don't know what causing this but this will be problem if I want to show some points which are at edge side. zoom level 13 is OK but on zoom level 18 will not have the way to go there.

I hope this will give you a brief idea about the issue.

aadi-github avatar Oct 14 '22 14:10 aadi-github

There's 2 separate things here (easy to get confused between them and maybe we should be clearer in the docs).

Limiting Pan from the center point (swPanBoundary/nePanBoundary), so the visible corners will change depending upon zoom. Limiting Pan for the corners, so nothing outside the bounds are visible. This is maxBounds. It sounds a little bit more like this is what you are after, but I may be wrong. If this is the one, check the the latest Git version, as there was a bug in 3.0.0 with maxBounds and interactions which was fixed later.

ibrierley avatar Oct 14 '22 15:10 ibrierley

There's 2 separate things here (easy to get confused between them and maybe we should be clearer in the docs).

Limiting Pan from the center point (swPanBoundary/nePanBoundary), so the visible corners will change depending upon zoom. Limiting Pan for the corners, so nothing outside the bounds are visible. This is maxBounds. It sounds a little bit more like this is what you are after, but I may be wrong. If this is the one, check the the latest Git version, as there was a bug in 3.0.0 with maxBounds and interactions which was fixed later.

Yes Actually, I will check with the latest Git version. Thankyou.

aadi-github avatar Oct 18 '22 11:10 aadi-github