Showing location directions (RDMLX)
Posted: Thu Jun 14, 2012 11:46 am
This is an example of how to display directions from one location to another, using google maps.
The directions can either appear in an imbedded web page, or opened in a separate browser window.
Function Options(*DIRECT)
begin_com role(*EXTENDS #LRNG_FORM)
define #W_LAT *dec 10 6
define #W_LON *dec 10 6
define #W_LOC *string
define #W_LOC2 *string
Mthroutine Name(HandleRequest) Options(*REDEFINE)
* -----------------------------------------
* Handle currently requested action
* -----------------------------------------
* Always set the USING Element to /Form.Fields at the start
#Com_Owner.Using Element('/Form.Fields')
Case Of_Field(#COM_OWNER.RequestACTION)
When (= SHOWPROG)
#COM_OWNER.IsNewForm := False
#COM_OWNER.Set_Label Name('/Form.Popover') Text('See Visual LANSA reusable part ' + #Com_Owner.Name) Color(Blue)
#Com_Owner.Set_Form Show_Popover(TRUE)
Otherwise /* Default */
#COM_OWNER.IsNewForm := True
#W_LAT := -33.8390190
#W_LON := 151.2098640
#W_LOC := '100 Miller St, North Sydney, Australia'
#W_LOC2 := '122 Arthur St, North Sydney, Australia'
Endcase
* --------------------------------------------------------------
* Format out the 'static' parts of the form view to be displayed
* --------------------------------------------------------------
#COM_OWNER.Set_Form Title('Location directions')
#COM_OWner.Set_Form Grid_Col_N(1) Grid_Col_Width(Fill)
#COM_OWner.Set_Form Grid_Row_N(2) Grid_Row_Height(Fill)
* Fields and web view
#Com_Owner.Set_Label Text('Show directions from a location to another location using google maps') Layout_Row(1) Layout_Col(1)
* replace all spaces in the addresses with +
#W_LOC := #W_LOC.ReplaceAll(' ' '+')
#W_LOC2 := #W_LOC2.ReplaceAll(' ' '+')
* Show a map in google maps (or the maps app) with the directions on it
*#COM_OWNER.Set_OpenURL Event('/Form.OnLoad') Url('http://maps.google.com/maps?saddr=' + #W_LAT.AsString + ',' + #W_LON.AsString + '&daddr=' + #W_LOC)
*or
* Show the directions in an imbedded web page
*#COM_OWNER.Set_WebView Name(SITEWEB) Layout_Row(2) Layout_Col(1) Url('http://maps.google.com/maps?saddr=' + #W_LAT.AsString + ',' + #W_LON.AsString + '&daddr=' + #W_LOC)
* or specify both addresses as street addresses - this makes it easier for the user to understand the directions
#COM_OWNER.Set_WebView Name(SITEWEB) Layout_Row(2) Layout_Col(1) Url('http://maps.google.com/maps?saddr=' + #W_LOC + '&daddr=' + #W_LOC2)
Endroutine
End_Com
The directions can either appear in an imbedded web page, or opened in a separate browser window.
Function Options(*DIRECT)
begin_com role(*EXTENDS #LRNG_FORM)
define #W_LAT *dec 10 6
define #W_LON *dec 10 6
define #W_LOC *string
define #W_LOC2 *string
Mthroutine Name(HandleRequest) Options(*REDEFINE)
* -----------------------------------------
* Handle currently requested action
* -----------------------------------------
* Always set the USING Element to /Form.Fields at the start
#Com_Owner.Using Element('/Form.Fields')
Case Of_Field(#COM_OWNER.RequestACTION)
When (= SHOWPROG)
#COM_OWNER.IsNewForm := False
#COM_OWNER.Set_Label Name('/Form.Popover') Text('See Visual LANSA reusable part ' + #Com_Owner.Name) Color(Blue)
#Com_Owner.Set_Form Show_Popover(TRUE)
Otherwise /* Default */
#COM_OWNER.IsNewForm := True
#W_LAT := -33.8390190
#W_LON := 151.2098640
#W_LOC := '100 Miller St, North Sydney, Australia'
#W_LOC2 := '122 Arthur St, North Sydney, Australia'
Endcase
* --------------------------------------------------------------
* Format out the 'static' parts of the form view to be displayed
* --------------------------------------------------------------
#COM_OWNER.Set_Form Title('Location directions')
#COM_OWner.Set_Form Grid_Col_N(1) Grid_Col_Width(Fill)
#COM_OWner.Set_Form Grid_Row_N(2) Grid_Row_Height(Fill)
* Fields and web view
#Com_Owner.Set_Label Text('Show directions from a location to another location using google maps') Layout_Row(1) Layout_Col(1)
* replace all spaces in the addresses with +
#W_LOC := #W_LOC.ReplaceAll(' ' '+')
#W_LOC2 := #W_LOC2.ReplaceAll(' ' '+')
* Show a map in google maps (or the maps app) with the directions on it
*#COM_OWNER.Set_OpenURL Event('/Form.OnLoad') Url('http://maps.google.com/maps?saddr=' + #W_LAT.AsString + ',' + #W_LON.AsString + '&daddr=' + #W_LOC)
*or
* Show the directions in an imbedded web page
*#COM_OWNER.Set_WebView Name(SITEWEB) Layout_Row(2) Layout_Col(1) Url('http://maps.google.com/maps?saddr=' + #W_LAT.AsString + ',' + #W_LON.AsString + '&daddr=' + #W_LOC)
* or specify both addresses as street addresses - this makes it easier for the user to understand the directions
#COM_OWNER.Set_WebView Name(SITEWEB) Layout_Row(2) Layout_Col(1) Url('http://maps.google.com/maps?saddr=' + #W_LOC + '&daddr=' + #W_LOC2)
Endroutine
End_Com