Commit e34c9983 authored by Camil Staps's avatar Camil Staps 🙂 Committed by Steffen Michels

Leaflet maps: only send fitbounds attribute to the client when necessary

parent 136eb606
Pipeline #44405 passed with stage
in 7 minutes and 22 seconds
......@@ -107,7 +107,6 @@ where
fromMaybe gDefault{|*|} $ editModeValue mode
# mapAttr = 'DM'.fromList
[("perspective", encodePerspective perspective)
,("fitbounds", encodeBounds (leafletBoundingRectangleOf (filteredObjects perspective val)))
,("tilesUrls"
, JSONArray $
(\tile ->
......@@ -119,6 +118,9 @@ where
tilesUrls
)
,("icons", JSONArray [toJSON (iconId,{IconOptions|iconUrl=iconUrl,iconSize=[w,h]}) \\ {iconId,iconUrl,iconSize=(w,h)} <- icons])
:if (perspective=:FitToBounds _ _)
[("fitbounds", encodeBounds (leafletBoundingRectangleOf (filteredObjects perspective val)))]
[]
]
# attr = 'DM'.unions
[ mapAttr
......@@ -750,7 +752,7 @@ where
# attrChanges = diffAttributes oldMap newMap
//Determine object changes
# childChanges = diffChildren oldMap.LeafletMap.objects newMap.LeafletMap.objects updateFromOldToNew encodeUI
# attrChanges = if (isEmpty childChanges)
# attrChanges = if (isEmpty childChanges || not (newMap.perspective=:FitToBounds _ _))
attrChanges
[SetAttribute "fitbounds" (encodeBounds (leafletBoundingRectangleOf (filteredObjects newMap.perspective newMap))):attrChanges]
= (Ok (ChangeUI attrChanges childChanges, newMap),vst)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment