Commit dc907eec authored by ecrombag's avatar ecrombag

Renamed the 'Map'-type to 'GoogleMap'

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@718 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent f653347d
......@@ -2,16 +2,17 @@ definition module GeoDomain
import Html, InteractionTasks, CommonDomain
derive gPrint Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gParse Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gVisualize Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gUpdate Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gPrint GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gParse GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVisualize GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gUpdate GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
//API Key for http://localhost
GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4lboFdTKu2o9gr_i8kRV0Pn1fNw"
:: StaticMap = StaticMap Int Int String
:: GoogleStaticMap = GoogleStaticMap Int Int String
:: Map =
:: GoogleMap =
{ center :: Coordinate // Coordinate of the center point (Required by maps)
, width :: Int // Width &
, height :: Int // Height of the map
......@@ -20,17 +21,17 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
, scaleControl :: Bool // Show the control for zooming
, zoom :: Int // The zoom level (Required by maps)
, mapType :: GoogleMapType // The map type
, markers :: [MapMarker] // Markers placed on the map
, markers :: [GoogleMapMarker] // Markers placed on the map
}
:: Coordinate :== (Real, Real) // (Lattitude, Longitude)
:: MapMarker =
{ position :: Coordinate // Coordinate of the marker point
, infoWindow :: MapInfoWindow // Information which is shown on click
:: GoogleMapMarker =
{ position :: Coordinate // Coordinate of the marker point
, infoWindow :: GoogleMapInfoWindow // Information which is shown on click
}
:: MapInfoWindow =
:: GoogleMapInfoWindow =
{ content :: String // Contents of the window
, width :: Int // Width of the window
}
......@@ -52,8 +53,7 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
:: ClickEvent = LEFTCLICK | RIGHTCLICK | DBLCLICK
:: ClickSource = MAP | MARKER Coordinate
convertToStaticMap :: Map -> StaticMap
mkMap :: Map
convertToStaticMap :: GoogleMap -> GoogleStaticMap
mkMap :: GoogleMap
instance toString GoogleMapType
//instance html StaticMap
......@@ -2,13 +2,13 @@ implementation module GeoDomain
import Html, InteractionTasks, StdEnv, JSON, CommonDomain
derive JSONEncode JSONMap, JSONStaticMap,MapMarker, GoogleMapType, MapInfoWindow
derive JSONEncode JSONMap, JSONStaticMap,GoogleMapMarker, GoogleMapType, GoogleMapInfoWindow
derive JSONDecode MVCUpdate, ClickUpdate, GoogleMapType, ClickSource, ClickEvent
derive gPrint Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gParse Map, MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gVisualize MapMarker, MapInfoWindow, GoogleMapType
derive gUpdate MapMarker, MapInfoWindow, GoogleMapType, StaticMap
derive gPrint GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gParse GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVisualize GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType
derive gUpdate GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
:: JSONMap =
{ center :: Coordinate
......@@ -19,7 +19,7 @@ derive gUpdate MapMarker, MapInfoWindow, GoogleMapType, StaticMap
, scaleControl :: Bool
, zoom :: Int
, mapType :: GoogleMapType
, markers :: [MapMarker]
, markers :: [GoogleMapMarker]
, xtype :: String
, id :: String
, name :: String
......@@ -42,7 +42,7 @@ where
toString HYBRID = "HYBRID"
toString TERRAIN = "TERRAIN"
gVisualize {|Map|} old new vst=:{vizType,label,idPrefix,currentPath, valid, optional}
gVisualize {|GoogleMap|} old new vst=:{vizType,label,idPrefix,currentPath, valid, optional}
= case vizType of
VEditorDefinition = ([TUIFragment (mapsPanel old True)], {VSt | vst & currentPath = stepDataPath currentPath })
VEditorUpdate
......@@ -58,25 +58,23 @@ where
jsonMap map editor =
{ JSONMap
| center = map.Map.center
, width = map.Map.width
, height = map.Map.height
, mapTypeControl = map.Map.mapTypeControl
, navigationControl = map.Map.navigationControl
, scaleControl = map.Map.scaleControl
, zoom = map.Map.zoom
, mapType = map.Map.mapType
, markers = map.Map.markers
| center = map.GoogleMap.center
, width = map.GoogleMap.width
, height = map.GoogleMap.height
, mapTypeControl = map.GoogleMap.mapTypeControl
, navigationControl = map.GoogleMap.navigationControl
, scaleControl = map.GoogleMap.scaleControl
, zoom = map.GoogleMap.zoom
, mapType = map.GoogleMap.mapType
, markers = map.GoogleMap.markers
, xtype = "itasks.gmappanel"
, name = dp2s currentPath
, id = dp2id idPrefix currentPath
, isEditor = editor
}
vizType = VHtmlDisplay
gVisualize {|StaticMap|} VBlank _ vst = ([TextFragment ""],vst)
gVisualize {|StaticMap|} (VValue (StaticMap w h u) _ ) _ vst=:{vizType,idPrefix,currentPath}
gVisualize {|GoogleStaticMap|} VBlank _ vst = ([TextFragment ""],vst)
gVisualize {|GoogleStaticMap|} (VValue (GoogleStaticMap w h u) _ ) _ vst=:{vizType,idPrefix,currentPath}
= case vizType of
VHtmlDisplay = ([HtmlFragment [ImgTag [SrcAttr u, WidthAttr (toString w), HeightAttr (toString h)]]],{VSt | vst & currentPath = stepDataPath currentPath})
//VHtmlDisplay = ([HtmlFragment [IframeTag [SrcAttr u, FrameborderAttr "0", WidthAttr (toString w), HeightAttr (toString h)][(Text "Cannot Display iFrame")]]],{VSt | vst & currentPath = stepDataPath currentPath})
......@@ -95,8 +93,8 @@ where
, url = u
}
gUpdate {|Map|} _ ust =: {USt | mode=UDCreate} = (
{ Map
gUpdate {|GoogleMap|} _ ust =: {USt | mode=UDCreate} = (
{ GoogleMap
| center = (51.82,5.86)
, width = 500
, height = 400
......@@ -108,7 +106,7 @@ gUpdate {|Map|} _ ust =: {USt | mode=UDCreate} = (
, markers = []
}, ust)
gUpdate {|Map|} s ust =: {USt | mode=UDSearch, searchPath, currentPath, update}
gUpdate {|GoogleMap|} s ust =: {USt | mode=UDSearch, searchPath, currentPath, update}
| currentPath == searchPath
= (parseUpdate s update, toggleMask {USt | ust & mode = UDDone})
| otherwise
......@@ -118,31 +116,25 @@ where
# mbMVC = fromJSON update
| isJust mbMVC
# mvc = fromJust mbMVC
//= case orig.Map.mvcFun of
// Nothing
= {Map | orig & center = mvc.MVCUpdate.center, zoom = mvc.MVCUpdate.zoom, mapType = mvc.MVCUpdate.type}
// (Just fun) = fun mvc
= {GoogleMap | orig & center = mvc.MVCUpdate.center, zoom = mvc.MVCUpdate.zoom, mapType = mvc.MVCUpdate.type}
# mbClick = fromJSON update
| isJust mbClick
# click = fromJust mbClick
//= case orig.Map.clickFun of
// Nothing = orig
// (Just fun) = fun click
# marker = {MapMarker | position = click.ClickUpdate.point, infoWindow = {MapInfoWindow | content = "", width=0}}
= {Map | orig & markers = [marker:orig.Map.markers]}
# marker = {GoogleMapMarker | position = click.ClickUpdate.point, infoWindow = {GoogleMapInfoWindow | content = "", width=0}}
= {GoogleMap | orig & markers = [marker:orig.GoogleMap.markers]}
| otherwise = orig
gUpdate {|Map|} s ust =: {USt | mode = UDMask, currentPath, mask}
gUpdate {|GoogleMap|} s ust =: {USt | mode = UDMask, currentPath, mask}
= (s, {USt | ust & currentPath = stepDataPath currentPath, mask = [currentPath:mask]})
gUpdate {|Map|} s ust = (s,ust)
gUpdate {|GoogleMap|} s ust = (s,ust)
//gUpdate {|StaticMap|} s ust =:{USt | currentPath, mask} = (s,{USt | ust & currentPath = stepDataPath currentPath, mask = [currentPath:mask]})
// -- Utility Functions --
mkMap :: Map
mkMap = { Map
mkMap :: GoogleMap
mkMap = { GoogleMap
| center = (0.0,0.0)
, width = 500
, height = 400
......@@ -154,21 +146,21 @@ mkMap = { Map
, markers = []
}
convertToStaticMap :: Map -> StaticMap
convertToStaticMap map =:{Map | center = (lat,lng), width, height, zoom, mapType, markers}
convertToStaticMap :: GoogleMap -> GoogleStaticMap
convertToStaticMap map =:{GoogleMap | center = (lat,lng), width, height, zoom, mapType, markers}
# url = "http://maps.google.com/maps/api/staticmap?"
# cntr = "center="+++(toString lat)+++","+++(toString lng)
# zm = "zoom="+++(toString zoom)
# sz = "size="+++(toString width)+++"x"+++(toString height)
# tp = "maptype="+++(toString mapType)
# mrkrs = "markers="+++(convertMarkers markers)
= StaticMap width height (url+++cntr+++"&"+++zm+++"&"+++sz+++"&"+++tp+++"&"+++mrkrs+++"&sensor=false&key="+++GOOGLE_API_KEY)
= GoogleStaticMap width height (url+++cntr+++"&"+++zm+++"&"+++sz+++"&"+++tp+++"&"+++mrkrs+++"&sensor=false&key="+++GOOGLE_API_KEY)
where
convertMarkers :: [MapMarker] -> String
convertMarkers :: [GoogleMapMarker] -> String
convertMarkers [] = "";
convertMarkers [x] = convertMarker x
convertMarkers [x:xs] = (convertMarker x)+++"|"+++(convertMarkers xs)
convertMarker :: MapMarker -> String
convertMarker :: GoogleMapMarker -> String
convertMarker mrkr =: {position = (lat,lng), infoWindow}
= toString lat+++","+++toString lng
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