Commit 64660fb0 authored by Bas Lijnse's avatar Bas Lijnse

First step in Google map refactoring

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1339 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 04bb0b5f
......@@ -22,6 +22,7 @@ import ChangeHandling
import textEditor
import CoffeeTime
import TableExamples
import GeoTracker
//Crisis response examples
import AmbulanceDispatch
......@@ -60,6 +61,7 @@ where
, textEditor
, coffeeTimeExample
, tableExamples
, geoTrackerExamples
, newsgroupsExample
, exceptionHandlingExample
, changeHandlingExample
......
......@@ -14,7 +14,7 @@ where
flows = [ workflow "Examples/Crisis response/Report incident (Map)" "" reportIncident]
:: Incident =
{ location :: Coordinate
{ location :: GoogleMapPosition
, address :: Note
, type :: IncidentType
, time :: Time
......@@ -39,7 +39,7 @@ specifiyIncidents map = sequence "Specify individual incident details" [ (addres
addressLookup :: GoogleMapMarker -> Task String
addressLookup marker
# (lat,lng) = marker.position
# {lat,lng} = marker.position
= showStickyMessage ("Address lookup","Address is being retrieved for coordinates: ("+++toString lat+++", "+++toString lng+++")") Void
||- reverse_geocoding (toString lat+++","+++toString lng) "json" False GOOGLE_API_KEY parseJSON
where
......
......@@ -83,7 +83,7 @@ where
emptyL = []
//Google Map Example
:: MarkerInfo = { position :: Coordinate
:: MarkerInfo = { position :: GoogleMapPosition
, map :: GoogleMap
}
:: MapSize = Normal | Large
......
definition module GeoTracker
import iTasks
geoTrackerExamples :: [Workflow]
\ No newline at end of file
implementation module GeoTracker
import iTasks
import GoogleMaps
geoTrackerExamples :: [Workflow]
geoTrackerExamples =
[workflow "Examples/Geo tracker/Report position" "Tell us where you are..." reportPosition
,workflow "Examples/Geo tracker/View map" "Look at the locations of users on the map." viewMap
]
reportPosition :: Task GoogleMapPosition
reportPosition = enterInformation "Where are you now?"
viewMap :: Task GoogleMap
viewMap = updateInformation "Look where everyone is" mkMap <<@ FWFullWidth
\ No newline at end of file
......@@ -4,13 +4,13 @@ definition module GoogleMaps
*/
import HTML, GenVisualize
derive gVisualize GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gUpdate GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gDefaultMask GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVerify GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONEncode GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONDecode GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gEq GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVisualize GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gUpdate GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gDefaultMask GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVerify GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONEncode GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONDecode GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gEq GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
//API Key for http://localhost
GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4lboFdTKu2o9gr_i8kRV0Pn1fNw"
......@@ -18,7 +18,7 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
:: GoogleStaticMap = GoogleStaticMap Int Int String
:: GoogleMap =
{ center :: Coordinate // Coordinate of the center point (Required by maps)
{ center :: GoogleMapPosition // 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
......@@ -32,10 +32,13 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
, markers :: [GoogleMapMarker] // Markers placed on the map
}
:: Coordinate :== (Real, Real) // (Lattitude, Longitude)
:: GoogleMapPosition =
{ lat :: !Real //Lattitude
, lng :: !Real //Longitude
}
:: GoogleMapMarker =
{ position :: Coordinate // Coordinate of the marker point
{ position :: GoogleMapPosition // Coordinate of the marker point
, infoWindow :: GoogleMapInfoWindow // Information which is shown on click
}
......@@ -47,7 +50,7 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
:: GoogleMapType = ROADMAP | SATELLITE | HYBRID | TERRAIN
:: MVCUpdate =
{ center :: Coordinate
{ center :: GoogleMapPosition
, zoom :: Int
, type :: GoogleMapType
}
......@@ -55,11 +58,11 @@ GOOGLE_API_KEY :== "ABQIAAAAaZ6XgbNqm4h_DL45IQMnSRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4
:: ClickUpdate =
{ event :: ClickEvent
, source :: ClickSource
, point :: Coordinate
, point :: GoogleMapPosition
}
:: ClickEvent = LEFTCLICK | RIGHTCLICK | DBLCLICK
:: ClickSource = MAP | MARKER Coordinate
:: ClickSource = MAP | MARKER GoogleMapPosition
/*
* Convert a dynamic map into a static image
......
......@@ -5,18 +5,24 @@ import HTML, StdEnv, JSON, GenUpdate, GenVisualize, GenVerify
derive JSONEncode TUIGoogleMap, TUIGoogleMapOptions, TUIGoogleStaticMap
derive JSONDecode MVCUpdate, ClickUpdate, ClickSource, ClickEvent
derive gVisualize GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType
derive gUpdate GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gDefaultMask GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVerify GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVisualize GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType
derive gUpdate GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gDefaultMask GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gVerify GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONEncode GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive JSONDecode GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gEq GoogleMap, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
derive gEq GoogleMap, GoogleMapPosition, GoogleMapMarker, GoogleMapInfoWindow, GoogleMapType, GoogleStaticMap
JSONEncode{|GoogleMapPosition|} {lat,lng} = [JSONArray [JSONReal lat,JSONReal lng]]
JSONDecode{|GoogleMapPosition|} [JSONArray [JSONReal lat,JSONReal lng]:rest]
= (Just {lat=lat,lng=lng},rest)
JSONDecode{|GoogleMapPosition|} rest = (Nothing,rest)
derive bimap Maybe, (,)
:: TUIGoogleMap =
{ center :: Coordinate
{ center :: GoogleMapPosition
, width :: Int
, height :: Int
, mapType :: GoogleMapType
......@@ -136,7 +142,7 @@ gDefaultMask{|GoogleMap|} _ = [Touched []]
mkMap :: GoogleMap
mkMap = { GoogleMap
| center = (51.82,5.86)
| center = {GoogleMapPosition|lat = 51.82, lng = 5.86}
, width = 710
, height = 300
, mapTypeControl = True
......@@ -152,7 +158,7 @@ mkMap = { GoogleMap
minimalMap :: GoogleMap
minimalMap = { GoogleMap
| center = (51.82,5.86)
| center = {GoogleMapPosition|lat = 51.82, lng = 5.86}
, width = 710
, height = 300
, mapTypeControl = False
......@@ -166,9 +172,8 @@ minimalMap = { GoogleMap
, markers = []
}
convertToStaticMap :: GoogleMap -> GoogleStaticMap
convertToStaticMap map =:{GoogleMap | center = (lat,lng), width, height, zoom, mapType, markers}
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)
......@@ -183,5 +188,5 @@ where
convertMarkers [x:xs] = (convertMarker x)+++"|"+++(convertMarkers xs)
convertMarker :: GoogleMapMarker -> String
convertMarker mrkr =: {position = (lat,lng), infoWindow}
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