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

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

Closed
maxgmer opened this issue Nov 27, 2018 · 20 comments
Closed

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

maxgmer opened this issue Nov 27, 2018 · 20 comments

Comments

@maxgmer
Copy link

maxgmer commented Nov 27, 2018

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.

@ibrierley
Copy link
Collaborator

ibrierley commented Dec 5, 2018

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).

@maxgmer
Copy link
Author

maxgmer commented Dec 6, 2018

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.

@KaYBlitZ
Copy link

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.

@OrKoN
Copy link
Contributor

OrKoN commented May 7, 2019

Does anyone have a workaround for this?

@OrKoN
Copy link
Contributor

OrKoN commented May 7, 2019

Selection_022

A screenshot to be clear about what issue I have.

@OrKoN
Copy link
Contributor

OrKoN commented May 7, 2019

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

@q869939686
Copy link

Selection_022

A screenshot to be clear about what issue I have.

Does anyone have a workaround for this?

@roderikpeeters
Copy link

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.

@github-actions
Copy link

github-actions bot commented Apr 5, 2021

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 github-actions bot added the Stale label Apr 5, 2021
@github-actions
Copy link

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

@andrekovac
Copy link

andrekovac commented May 30, 2021

@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!

@mchesnokov
Copy link

Needs re-open.

@NemanjaLugi
Copy link

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.

@ibrierley
Copy link
Collaborator

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

@fleaflet fleaflet deleted a comment from aadi-github Oct 12, 2022
@JaffaKetchup
Copy link
Member

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

@aadi-github
Copy link

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.

@ibrierley
Copy link
Collaborator

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

@aadi-github
Copy link

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.

@ibrierley
Copy link
Collaborator

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.

@aadi-github
Copy link

aadi-github commented Oct 18, 2022

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.

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