Commit b64c2fa7 authored by Bas Lijnse's avatar Bas Lijnse

Added possibility to select markers on a google map

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2364 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 8f0e2682
......@@ -84,7 +84,6 @@ Ext.define('itwc.component.edit.GoogleMap',{
me.viewport = me.viewport || me.up('viewport');
me.viewport.fireEvent('edit',me.taskId, me.editorId,e);
};
//Add perspective change
......@@ -138,9 +137,16 @@ Ext.define('itwc.component.edit.GoogleMap',{
};
google.maps.event.addListener(marker,'click',clickHandler(map,marker,infoWindow));
} else {
clickHandler = function(markerId) { return function(e) {
me.viewport = me.viewport || me.up('viewport');
me.viewport.fireEvent('edit',me.taskId, me.editorId,{index: markerId, event: "LEFTCLICK",});
};};
google.maps.event.addListener(marker,'click',clickHandler(i));
}
if(this.markers[i].draggable) {
dragHandler = function(markerId) { return function(e) {
me.viewport = me.viewport || me.up('viewport');
me.viewport.fireEvent('edit',me.taskId, me.editorId,{index: markerId, point : [e.latLng.lat(),e.latLng.lng()]});
......@@ -160,6 +166,16 @@ Ext.define('itwc.component.edit.GoogleMap',{
}
this.callParent(arguments);
},
setValue: function(value) {
},
update: function(def) {
var me = this;
//Update perspective
//Update markers
console.log(def);
},
onDestroy: function() {
if(this.map) {
google.maps.event.clearInstanceListeners(this.map);
......
......@@ -160,10 +160,11 @@ where
hasMargin control = isJust (getSizeOpts control).UISizeOpts.margins
noMarginControl (UIPanel _ _ _) = True
noMarginControl (UIGrid _ _ _) = True
noMarginControl (UITree _ _) = True
noMarginControl _ = False
noMarginControl (UIPanel _ _ _) = True
noMarginControl (UIGrid _ _ _) = True
noMarginControl (UITree _ _) = True
noMarginControl (UIEditGoogleMap _ _ _) = True
noMarginControl _ = False
//Wrap the controls of the prompt in a container with a nice css class and add some bottom margin
decoratePrompt :: [(UIControl,UIAttributes)] -> [UIControl]
......
......@@ -618,20 +618,23 @@ gVisualizeText{|GoogleMapPosition|} _ {GoogleMapPosition|lat,lng} = [toString l
, type :: !GoogleMapType
}
:: ClickUpdate =
:: MapClickUpdate =
{ event :: !ClickEvent
, source :: !ClickSource
, point :: !(Real,Real)
}
:: ClickEvent = LEFTCLICK | RIGHTCLICK | DBLCLICK
:: ClickSource = MAP | MARKER (Real,Real)
:: MarkerClickUpdate =
{ index :: !Int
, event :: !ClickEvent
}
:: MarkerDragUpdate =
{ index :: !Int
, point :: !(Real,Real)
}
derive JSONDecode MVCUpdate, ClickUpdate, ClickEvent, ClickSource, MarkerDragUpdate
derive JSONDecode MVCUpdate, MapClickUpdate, ClickEvent, MarkerClickUpdate, MarkerDragUpdate
gUpdate{|GoogleMap|} target upd val = basicUpdate parseUpdate target upd val
where
......@@ -640,19 +643,19 @@ where
| isJust mbMVC
# {MVCUpdate|center=(lat,lng),zoom,type} = fromJust mbMVC
= {GoogleMap | orig & perspective = {GoogleMapPerspective|orig.perspective & center = {lat=lat,lng=lng}, zoom = zoom, type = type}}
# mbClick = fromJSON json
| isJust mbClick
# click = fromJust mbClick
# marker = {GoogleMapMarker | position = {lat=fst click.ClickUpdate.point,lng=snd click.ClickUpdate.point}, title = Nothing, icon = Nothing, infoWindow = Nothing, draggable = True, selected = False}
= {GoogleMap | orig & markers = orig.GoogleMap.markers ++ [marker]}
# mbMarkerDrag = fromJSON json
| isJust mbMarkerDrag
# {MarkerDragUpdate|index,point=(lat,lng)} = fromJust mbMarkerDrag
= {GoogleMap | orig & markers = [if (i == index) {GoogleMapMarker|m & position = {lat=lat,lng=lng}} m \\ m <- orig.GoogleMap.markers & i <- [0..]]}
| otherwise = orig
# mbMarkerClick = fromJSON json
| isJust mbMarkerClick
# {MarkerClickUpdate|index,event} = fromJust mbMarkerClick
= {GoogleMap| orig & markers = [{GoogleMapMarker|m & selected = i == index} \\ m <- orig.GoogleMap.markers & i <- [0..]]}
| otherwise
= orig
gVerify{|GoogleMap|} _ um _ = alwaysValid um
//derive gVerify GoogleMap
gDefault{|GoogleMapPerspective|} _ =
{ GoogleMapPerspective
......
......@@ -270,7 +270,9 @@ gVisualizeEditor{|(->)|} _ _ _ _ _ _ _ _ _ vst = noVisualization vst
gVisualizeEditor{|Dynamic|} _ vst = noVisualization vst
gVisualizeEditor{|Maybe|} fx _ _ _ val vst=:{VSt|currentPath,optional}
gVisualizeEditor{|Maybe|} fx _ _ _ val vst=:{VSt|currentPath,optional,disabled}
| disabled && noValue val
= (OptionalEditor [], {VSt|vst & currentPath = stepDataPath currentPath})
# (viz,vst) = case val of
Just (Just x) = fx (Just x) {VSt|vst & optional = True}
_ = fx Nothing {VSt|vst & optional = True}
......@@ -278,8 +280,11 @@ gVisualizeEditor{|Maybe|} fx _ _ _ val vst=:{VSt|currentPath,optional}
where
toOptional (NormalEditor ex) = OptionalEditor ex
toOptional viz = viz
noValue (Just Nothing) = True
noValue Nothing = True
noValue _ = False
gVisualizeEditor{|Void|} _ vst = noVisualization vst
gVisualizeEditor{|HtmlTag|} val vst = visualizeCustom toControl vst
where
......
......@@ -76,8 +76,8 @@ diffControls path event c1 c2
= [diffSizeOpts path sOpts1 sOpts2,diffEditOpts path event eOpts1 eOpts2]
(UIEditButton sOpts1 eOpts1 opts1, UIEditButton sOpts2 eOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffEditOpts path event eOpts1 eOpts2,diffOpts opts1 opts2]
(UIEditGoogleMap sOpts1 eOpts1 opts1, UIEditGoogleMap sOpts2 eOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffEditOpts path event eOpts1 eOpts2,diffOpts opts1 opts2]
(m1=:UIEditGoogleMap sOpts1 eOpts1 opts1,m2=:UIEditGoogleMap sOpts2 eOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts eOpts1 eOpts2, diffOpts opts1 opts2/* clientSideUpdate path m1 m2 */]
(UIEditCode sOpts1 eOpts1 opts1, UIEditCode sOpts2 eOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffEditOpts path event eOpts1 eOpts2,diffOpts opts1 opts2]
(UIDropdown sOpts1 cOpts1, UIDropdown sOpts2 cOpts2)
......@@ -156,7 +156,7 @@ where
valueUpd
| eventMatch opts2 event
# value2 = encodeUIValue opts2.UIEditOpts.value
= if (eventValue event === value2) [] [UISetValue (toString path) value2]
= if (eventValue event === value2) [] [UISetValue (toString path) value2]
| otherwise
= if (opts1.UIEditOpts.value === opts2.UIEditOpts.value) [] [UISetValue (toString path) (encodeUIValue opts2.UIEditOpts.value)]
......@@ -192,6 +192,12 @@ diffOpts opts1 opts2
| opts1 === opts2 = DiffPossible []
= DiffImpossible
//Let the client figure out the update if there are differences
clientSideUpdate :: DiffPath UIControl UIControl -> DiffResult
clientSideUpdate path c1 c2
| c1 === c2 = DiffPossible []
= DiffPossible [UIUpdate (toString path) c2]
//Specialized diffs for the control specific options
diffPanelOpts :: DiffPath Event UIPanelOpts UIPanelOpts -> DiffResult
diffPanelOpts path event opts1 opts2
......
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