diff --git a/Client/index.html b/Client/index.html
index 0e72ba99abc446f0b7844e1e0a6d3ef9aad65ca6..112cba1d2a64e4ed2707be92da457fa06538bb7b 100644
--- a/Client/index.html
+++ b/Client/index.html
@@ -15,6 +15,9 @@
+
+
+
diff --git a/Client/js/itasks.GMapPanel.js b/Client/js/itasks.GMapPanel.js
index a9597e426c49286c7289a9113155fd8a3058a7b2..a727cecf28fd32e8dfff1be3135a73e26580b634 100644
--- a/Client/js/itasks.GMapPanel.js
+++ b/Client/js/itasks.GMapPanel.js
@@ -14,6 +14,7 @@ itasks.GMapPanel = Ext.extend( Ext.Panel, {
, height: 400
, width: 500
, scope: this
+ , displayedMarkers : new Array()
});
itasks.GMapPanel.superclass.initComponent.apply(this,arguments);
@@ -26,6 +27,8 @@ itasks.GMapPanel = Ext.extend( Ext.Panel, {
//this.gmap.setCenter(new google.maps.LatLng(data.center[0],data.center[1]));
//this.gmap.setZoom(data.zoom);
//this.gmap.setMapTypeId(this.getMapType(data.mapType));
+ this.markers = data.markers;
+ this.addMarkers();
},
getMapType : function (mapType){
@@ -45,7 +48,7 @@ itasks.GMapPanel = Ext.extend( Ext.Panel, {
this.gmap = new google.maps.Map(this.body.dom, options);
- //this.addMarkers(gmap)
+ this.addMarkers()
var parent = this;
@@ -92,14 +95,22 @@ itasks.GMapPanel = Ext.extend( Ext.Panel, {
},
- addMarkers : function (gmap){
+ addMarkers : function (){
var i=0;
+ for(i=0; i>=
+ \map -> specifiyIncidents map
+ >>| return Void
+
+markLocations :: Task Map
+markLocations =
+ enterInformation "Mark all locations where incidents have occurred"
+
+specifiyIncidents :: Map -> Task [Incident]
+specifiyIncidents map = sequence "Specify individual incident details" [ (specifyIncident m) \\ m <- map.Map.markers ]
+
+specifyIncident :: MapMarker -> Task Incident
+specifyIncident marker
+# smap = convertToStaticMap {Map | mkMap & center = marker.position, width = 200, height = 200, zoom = 15, markers = [marker]}
+# incident = { Incident
+ | location = marker.position
+ , type = Accident
+ , time = {Time | hour = 0, min = 0, sec = 0}
+ , nrInjured = 0
+ , description = ""
+ }
+= showStickyMessage smap ||- updateInformation "Specify incident details" incident
\ No newline at end of file
diff --git a/Libraries/iTasks/Domains/GeoDomain.dcl b/Libraries/iTasks/Domains/GeoDomain.dcl
index 62d45cec3e3f5db6087fc757c93648534a5d77e0..136696d6398e4f045ae464cd15791b10d8b3a28b 100644
--- a/Libraries/iTasks/Domains/GeoDomain.dcl
+++ b/Libraries/iTasks/Domains/GeoDomain.dcl
@@ -1,22 +1,26 @@
definition module GeoDomain
-import Html, InteractionTasks
+import Html, InteractionTasks, CommonDomain
derive gPrint Map, MapMarker, MapInfoWindow, GoogleMapType
derive gParse Map, MapMarker, MapInfoWindow, GoogleMapType
derive gVisualize Map, MapMarker, MapInfoWindow, GoogleMapType
derive gUpdate Map, MapMarker, MapInfoWindow, GoogleMapType
+GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRSrEXT3fNkwKSNTH8TDIqmpG-dFexSqJbR7bjG_6PAGWu4c1EGXviNLNQ"
+
+:: StaticMap = StaticMap Int Int String
+
:: Map =
- { center :: Coordinate // Coordinate of the center point (Required by maps)
- , width :: Int // Width &
- , height :: Int // Height of the map
- , mapTypeControl :: Bool // Show the control for switching between map types
- , navigationControl :: Bool // Show the control for panning
- , 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
+ { center :: Coordinate // Coordinate of the center point (Required by maps)
+ , width :: Int // Width &
+ , height :: Int // Height of the map
+ , mapTypeControl :: Bool // Show the control for switching between map types
+ , navigationControl :: Bool // Show the control for panning
+ , 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
}
:: Coordinate :== (Real, Real) // (Lattitude, Longitude)
@@ -33,4 +37,23 @@ derive gUpdate Map, MapMarker, MapInfoWindow, GoogleMapType
:: GoogleMapType = ROADMAP | SATELLITE | HYBRID | TERRAIN
+:: MVCUpdate =
+ { center :: Coordinate
+ , zoom :: Int
+ , type :: GoogleMapType
+ }
+
+:: ClickUpdate =
+ { event :: ClickEvent
+ , source :: ClickSource
+ , point :: Coordinate
+ }
+
+:: ClickEvent = LEFTCLICK | RIGHTCLICK | DBLCLICK
+:: ClickSource = MAP | MARKER Coordinate
+
+convertToStaticMap :: Map -> StaticMap
+mkMap :: Map
+
instance toString GoogleMapType
+instance html StaticMap
diff --git a/Libraries/iTasks/Domains/GeoDomain.icl b/Libraries/iTasks/Domains/GeoDomain.icl
index 9426704e6a658cf0393917273e9fb12f97033ac7..e5519a8d7ce8bc696c93e3b0147ee49ecb9d96f2 100644
--- a/Libraries/iTasks/Domains/GeoDomain.icl
+++ b/Libraries/iTasks/Domains/GeoDomain.icl
@@ -1,6 +1,6 @@
implementation module GeoDomain
-import Html, InteractionTasks, StdEnv, JSON
+import Html, InteractionTasks, StdEnv, JSON, CommonDomain
derive JSONEncode JSONMap, MapMarker, GoogleMapType, MapInfoWindow
derive JSONDecode MVCUpdate, ClickUpdate, GoogleMapType, ClickSource, ClickEvent
@@ -26,21 +26,6 @@ derive gUpdate MapMarker, MapInfoWindow, GoogleMapType
, isEditor :: Bool
}
-:: MVCUpdate =
- { center :: Coordinate
- , zoom :: Int
- , type :: GoogleMapType
- }
-
-:: ClickUpdate =
- { event :: ClickEvent
- , source :: ClickSource
- , point :: Coordinate
- }
-
-:: ClickEvent = LEFTCLICK | RIGHTCLICK | DBLCLICK
-:: ClickSource = MAP | MARKER Coordinate
-
instance toString GoogleMapType
where
toString ROADMAP = "ROADMAP"
@@ -48,6 +33,10 @@ where
toString HYBRID = "HYBRID"
toString TERRAIN = "TERRAIN"
+instance html StaticMap
+where
+ html (StaticMap width height url) = [DivTag [WidthAttr (toString width), HeightAttr (toString height)] [ImgTag [SrcAttr url, WidthAttr (toString width), HeightAttr (toString height)]]]
+
gVisualize {|Map|} old new vst=:{vizType,label,idPrefix,currentPath, valid, optional}
= case vizType of
VEditorDefinition = ([TUIFragment (mapsPanel old True)], {VSt | vst & currentPath = stepDataPath currentPath })
@@ -102,15 +91,55 @@ 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
# mbClick = fromJSON update
| isJust mbClick
# click = fromJust mbClick
- # marker = {MapMarker | position = click.ClickUpdate.point, infoWindow = {MapInfoWindow | content = "HI!", width=200}}
- = {Map | orig & markers = [marker : orig.Map.markers]}
+ //= 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]}
| otherwise = orig
gUpdate {|Map|} s ust =: {USt | mode = UDMask, currentPath, mask}
= (s, {USt | ust & currentPath = stepDataPath currentPath, mask = [currentPath:mask]})
-gUpdate {|Map|} s ust = (s,ust)
\ No newline at end of file
+gUpdate {|Map|} s ust = (s,ust)
+
+// -- Utility Functions --
+
+mkMap :: Map
+mkMap = { Map
+ | center = (0.0,0.0)
+ , width = 500
+ , height = 400
+ , mapTypeControl = True
+ , navigationControl = True
+ , scaleControl = True
+ , zoom = 10
+ , mapType = ROADMAP
+ , markers = []
+ }
+
+convertToStaticMap :: Map -> StaticMap
+convertToStaticMap map =:{Map | 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)
+where
+ convertMarkers :: [MapMarker] -> String
+ convertMarkers [] = "";
+ convertMarkers [x] = convertMarker x
+ convertMarkers [x:xs] = (convertMarker x)+++"|"+++(convertMarkers xs)
+
+ convertMarker :: MapMarker -> String
+ convertMarker mrkr =: {position = (lat,lng), infoWindow}
+ = toString lat+++","+++toString lng