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

ability to set max and min width, height #4

Open
snario opened this issue May 5, 2014 · 6 comments
Open

ability to set max and min width, height #4

snario opened this issue May 5, 2014 · 6 comments

Comments

@snario
Copy link

snario commented May 5, 2014

As the title says. Essentially my goal is to create rectangles that are limited on size in sq. km for example no rectangle greater than 900 sq. km.

However in this case limiting the zoom level and then also limiting this to say 500px would work great

@heyman
Copy link
Owner

heyman commented May 5, 2014

I agree, that would be really nice. Unfortunately, I don't think I'll have the time to implement any time soon. I'd be happy to accept pull requests though.

@snario
Copy link
Author

snario commented May 5, 2014

I can have a look if I have some time in the coming weeks

On Mon, May 5, 2014 at 4:44 PM, Jonatan Heyman [email protected]:

I agree, that would be really nice. Unfortunately, I don't think I'll have
the time to implement any time soon. I'd be happy to accept pull requests
though.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-42237016
.

@heyman
Copy link
Owner

heyman commented May 5, 2014

That'd be great!

On Mon, May 5, 2014 at 10:45 PM, Liam Horne [email protected]:

I can have a look if I have some time in the coming weeks

On Mon, May 5, 2014 at 4:44 PM, Jonatan Heyman [email protected]:

I agree, that would be really nice. Unfortunately, I don't think I'll
have
the time to implement any time soon. I'd be happy to accept pull
requests
though.


Reply to this email directly or view it on GitHub<
https://github.com/heyman/leaflet-areaselect/issues/4#issuecomment-42237016>

.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-42237147
.

@jase88
Copy link

jase88 commented Aug 11, 2014

Sounds great any updates on this?

@snario
Copy link
Author

snario commented Aug 11, 2014

I haven't tackled this sorry, I was using this for a bit on a project I'm working on but switched to Leaflet Draw for my particular need and so just haven't needed to extend this functionality.

@jase88
Copy link

jase88 commented Aug 14, 2014

Okay thanks anyway for your quick reply.

So basically there are two events that have to be considered when limiting the size of an area:

  1. Changing zoom level
  2. Changing the selected area itself (mouse)

Next step: How to handle this?
Ok when you're dragging an area that would be too big, dragging should be stopped at maximum.
But zooming? I guess it would be the best to set the size of the area to the maximum on this zoom instead of preventing the whole zoom interaction.

It would be great to limit the size in square degrees because OpenStreetMap is limiting requests to their API with fixed area sizes in square degrees (e.g. Notes API 25 square degrees). Normally you would do that with (sin(maxlat)-sin(minlat)) * (maxlon-minlon). But the OSM backend simplifies this by removing the trigonometric functions, so it's just (maxlat-minlat)*(maxlon-minlon). Like this:

areaSelect.on("change", function() {
var bbox=this.getBounds();
var area = (bbox._northEast.lat-bbox._southWest.lat)*(bbox._northEast.lng-bbox._southWest.lng);
if(area<25)
  Session.set("bounds", this.getBounds());
else
  delete Session.keys['bounds'];
});

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