bozdoz / wp-plugin-leaflet-map

Add leaflet maps to Wordpress with shortcodes
https://wordpress.org/plugins/leaflet-map/
GNU General Public License v2.0
140 stars 71 forks source link

zoom validation #189

Closed hupe13 closed 1 year ago

hupe13 commented 1 year ago

https://github.com/bozdoz/wp-plugin-leaflet-map/blob/fa440060e7b9a0b77dc160a8adc201801502e77c/shortcodes/class.map-shortcode.php#L215 should be 'zoom' => FILTER_VALIDATE_INT,

here also: https://github.com/bozdoz/wp-plugin-leaflet-map/blob/fa440060e7b9a0b77dc160a8adc201801502e77c/shortcodes/class.map-shortcode.php#L159

Should I change this?

bozdoz commented 1 year ago

why INT?

hupe13 commented 1 year ago

Today I answered a support question. Apologies for communicating in german, we then switched to mail. The problem was, some markers were displayed, others not. The reason was, the user has defined a floating point number for min_zoom: "2.7". Then he defined "2" and it worked. I was able to reproduce the error.

I read the documentation about zoom again. Floating point numbers only occur when fractional zoom is used. Such an option does not exist in Leaflet Map.

Valid values for min_zoom, max_zoom and zoom are integers from 0 to 20. max_zoom depends on the used tiles.

bozdoz commented 1 year ago

I think I understand. Zoom can be fractional, min and max can only be ints. Is that true?

hupe13 commented 1 year ago

Yes, min and max should be ints. From the documentation:

Fractional zoom is disabled by default. To enable it, use the map’s zoomSnap option.

This is not used in Leaflet Map, therefore values for zoom should be int.