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

Update examples and tests for changes in leaflet library

parent 66a1eb4c
......@@ -69,7 +69,7 @@ toLeafletMap :: ContactMap -> LeafletMap
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
fromLeafletMap :: ContactMap LeafletMap -> ContactMap
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
perspectiveFromLeafletMap :: LeafletMap -> ContactMapPerspective
selectionFromLeafletMap :: LeafletMap -> [LeafletObjectID]
......
......@@ -133,7 +133,8 @@ hasLatLng _ = False
toLeafletMap :: ContactMap -> LeafletMap
toLeafletMap {ContactMap|perspective,layers}
= {LeafletMap|perspective = toLeafletPerspective perspective
= {LeafletMap|defaultValue
&perspective = toLeafletPerspective perspective
,tilesUrls = tilesUrls layers
,icons = shipIcons
,objects = []
......@@ -182,8 +183,8 @@ where
*/
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
toLeafletPerspective {ContactMapPerspective|center,zoom,cursor,bounds}
= {LeafletPerspective|center=toLeafletLatLng center,zoom=zoom,bounds=fmap toLeafletBounds bounds}
toLeafletPerspective {ContactMapPerspective|center,zoom}
= CenterAndZoom (toLeafletLatLng center) zoom
toLeafletLatLng :: !(!Real,!Real) -> LeafletLatLng
toLeafletLatLng (lat,lng) = {LeafletLatLng|lat=lat,lng=lng}
......@@ -194,13 +195,13 @@ toLeafletBounds (sw,ne) = {LeafletBounds|southWest=toLeafletLatLng sw,northEast=
fromLeafletMap :: ContactMap LeafletMap -> ContactMap
fromLeafletMap contactMap leafletMap
= {ContactMap|contactMap
&perspective = fromLeafletPerspective leafletMap.LeafletMap.perspective
&perspective = perspectiveFromLeafletMap leafletMap
/*,layers = [fromLeafletLayer cl ll \\ cl <- contactMap.ContactMap.layers & ll <- leafletMap.LeafletMap.layers]*/
}
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
fromLeafletPerspective {LeafletPerspective|center,zoom,bounds}
= {ContactMapPerspective|center=fromLeafletLatLng center,zoom=zoom,cursor=Nothing,bounds=fmap fromLeafletBounds bounds}
perspectiveFromLeafletMap :: LeafletMap -> ContactMapPerspective
perspectiveFromLeafletMap {LeafletMap|center,zoom,bounds}
= {ContactMapPerspective|center=fromLeafletLatLng (fromJust center),zoom=fromJust zoom,cursor=Nothing,bounds=fmap fromLeafletBounds bounds}
/*
fromLeafletLayer :: ContactMapLayer LeafletLayer -> ContactMapLayer
......
......@@ -36,8 +36,8 @@ where
where
toMap baseLayers (perspective,contacts)
= toLeafletMap {ContactMap| perspective = perspective, layers = baseLayers ++ [{title="Contacts",def=CMMarkersLayer [contactGeoToMapMarker False False c \\ c=:{ContactGeo|position=Just _} <- contacts]}]}
fromMap _ {LeafletMap|perspective}
= fromLeafletPerspective perspective
fromMap _ map
= perspectiveFromLeafletMap map
configure "Incident"
= Title title @>> enterChoiceWithSharedAs [ChooseFromList bigLabel] allIncidentsShort (\{IncidentShort|incidentNo} -> WallIncidentSummary (Just incidentNo))
configure "Contact"
......
......@@ -596,8 +596,8 @@ where
toPrj baseLayers (contacts,sel,perspective)
= toLeafletMap {ContactMap|perspective=perspective,layers=[{title="Contacts",def=CMMarkersLayer (toMarkers sel contacts)}:baseLayers]}
fromPrj (contacts,sel,_) map=:{LeafletMap|perspective}
= (maybe sel Just (updateSelection (selectionFromLeafletMap map)),fromLeafletPerspective perspective)
fromPrj (contacts,sel,_) map
= (maybe sel Just (updateSelection (selectionFromLeafletMap map)),perspectiveFromLeafletMap map)
selection (Value (Just no,_) stable) = Value no stable
selection _ = NoValue
......
......@@ -232,7 +232,7 @@ where
\perspective -> (Title "Preview" @>> updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] (perspective >*| standardMapLayers)) <<@ ApplyLayout flexMap @ fst
where
toPrj (perspective,layers) = toLeafletMap {ContactMap|defaultValue & perspective=perspective,layers=layers}
fromPrj _ {LeafletMap|perspective} = fromLeafletPerspective perspective
fromPrj _ map = perspectiveFromLeafletMap map
flexMap = layoutSubUIs (SelectByPath [1]) (setUIAttributes (sizeAttr FlexSize FlexSize))
configureWebLinks :: Task ()
......
......@@ -11,6 +11,7 @@ import qualified Data.IntMap.Strict as DIS
import qualified Data.Map as DM
import Data.Map.GenJSON
import qualified Data.Set as DS
import Data.Set.GenJSON
import Text.HTML
import Data.Functor
......@@ -25,11 +26,6 @@ derive class iTask ObjectType, ActorStatus, Availability, ActorHealth, ActorEner
derive class iTask Cable, Priority, Network, Device, CableType, DeviceKind, CommandAim, Capability, CapabilityExpr
derive gHash Capability
derive gEditor Set
derive gText Set
derive JSONEncode Set
derive JSONDecode Set
// std overloading instances
//instance == Object where (==) o1 o2 = o1 === o2
......
......@@ -56,7 +56,7 @@ toLeafletMap :: ContactMap -> LeafletMap
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
fromLeafletMap :: LeafletMap -> ContactMap
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
perspectiveFromLeafletMap :: LeafletMap -> ContactMapPerspective
derive class iTask ContactMap, ContactMapMarker, ContactMapMarkerType
derive JSONEncode ContactMapPerspective
......
......@@ -109,7 +109,8 @@ cat _ = 0
toLeafletMap :: ContactMap -> LeafletMap
toLeafletMap {ContactMap|perspective,markers}
= {LeafletMap|perspective = toLeafletPerspective perspective
= {LeafletMap|defaultValue
&perspective = toLeafletPerspective perspective
,icons = [icon i \\ i <- [1..250]]
,tilesUrls = [{url = TILESERVER, attribution = Nothing}]
,objects = convMarkers markers //Just the baselayer
......@@ -123,8 +124,8 @@ where
iconIndex heading type selected = toString (cat type + ( (maybe 24 (\d -> toInt d / 15) heading) + (if selected 25 0)) * 5)
toLeafletPerspective :: ContactMapPerspective -> LeafletPerspective
toLeafletPerspective {ContactMapPerspective|center,zoom,cursor}
= {LeafletPerspective|center=toLeafletLatLng center,zoom=zoom,bounds=Nothing}
toLeafletPerspective {ContactMapPerspective|center,zoom}
= CenterAndZoom (toLeafletLatLng center) zoom
toLeafletLatLng :: !LatLng -> LeafletLatLng
toLeafletLatLng (lat,lng) = {LeafletLatLng | lat = toDeg lat, lng = toDeg lng}
......@@ -133,16 +134,14 @@ fromLeafletLatLng :: !LeafletLatLng -> LatLng
fromLeafletLatLng {LeafletLatLng | lat, lng} = (deg lat, deg lng)
fromLeafletMap :: LeafletMap -> ContactMap
fromLeafletMap {LeafletMap|perspective,objects}
= {ContactMap|perspective = fromLeafletPerspective perspective
fromLeafletMap map=:{LeafletMap|objects}
= {ContactMap|perspective = perspectiveFromLeafletMap map
,markers=toMarkers objects}
where
toMarkers objects
= [{ContactMapMarker|markerId=markerId,title=Nothing,position = fromLeafletLatLng position, type=Nothing,heading=Nothing,selected=False}
\\ Marker {LeafletMarker|markerId = LeafletObjectID markerId,position} <- objects]
fromLeafletPerspective :: LeafletPerspective -> ContactMapPerspective
fromLeafletPerspective {LeafletPerspective|center,zoom}
= {ContactMapPerspective|center=fromLeafletLatLng center,zoom=zoom,cursor=Nothing}
perspectiveFromLeafletMap :: LeafletMap -> ContactMapPerspective
perspectiveFromLeafletMap {LeafletMap|center,zoom}
= {ContactMapPerspective|center=fromLeafletLatLng (fromJust center),zoom=fromJust zoom,cursor=Nothing}
......@@ -5,6 +5,7 @@ import C2.Framework.Entity
import C2.Apps.ShipAdventure.Scripting, C2.Apps.ShipAdventure.Core, C2.Apps.ShipAdventure.Types, C2.Apps.ShipAdventure.Images, C2.Framework.Logging
from Data.Set import :: Set
import qualified Data.Set as DS
import Data.Set.GenJSON
from Data.IntMap.Strict import instance Functor IntMap
import qualified Data.IntMap.Strict as DIS
import C2.Apps.ShipAdventure.Editor
......@@ -12,11 +13,6 @@ import C2.Apps.ShipAdventure.Types
import Data.Map.GenJSON
import Data.Functor
derive gEditor Set
derive gText Set
derive JSONEncode Set
derive JSONDecode Set
dOffRegisterEntity :: [User -> Task Entity]
dOffRegisterEntity = []
......
......@@ -2,7 +2,7 @@ module TestLeafletResize
import iTasks
import iTasks.Extensions.GIS.Leaflet
test = ((Hint "Map resizing" @>> viewInformation [] {LeafletMap|perspective=defaultValue,objects=objects,tilesUrls=[],icons=[]}) <<@ FlexInner <<@ AddCSSClass "itasks-flex-height")
test = ((Hint "Map resizing" @>> viewInformation [] {LeafletMap|defaultValue&perspective=defaultValue,objects=objects,tilesUrls=[],icons=[]}) <<@ FlexInner <<@ AddCSSClass "itasks-flex-height")
-|| ((Hint "List to force resizing" @>> updateInformation [] [1,2,3,4]) <<@ AddCSSClass "itasks-wrap-height")
where
......
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