How to open Google Map in the mobile application

You can call the Google Map native app or the Google Map Web app, depending on the mobile OS. For iOS, you can either call the native app or the Web app; while for Android, you can only call the Web app.

To call the Google Map native app:

First define a function to call the Google Map native app via its URL scheme. Note that URL scheme is supported in iOS only.

public function integer of_gm_direction (string as_saddr, string as_daddr , string as_dirmode);

// Only iOS can support google map URL Scheme
// as_dirmode:driving,transit,bicycling,walking

string ls_url, ls_urlscheme
inet l_inet
integer li_re

ls_urlscheme = "comgooglemaps://?saddr="+as_saddr+"&daddr="+as_daddr+"&dirflag="+as_dirmode

l_inet = create inet
li_re = l_inet.hyperlinktourl(ls_urlscheme ) 

destroy l_inet
end function

Call the function by passing in the start address, destination address, and direction mode. For example:

  • The address can either be the name of places (using + as separator) or the latitude and longitude.

  • The direction mode can be: driving, transit, bicycling, walking.

of_gm_direction("22.549721,113.948371","22.5584634,114.1337181","bicycling")

Or

of_gm_direction("appeon+sz+Guangdong+china","22.5584634,114.1337181","driving")

To call the Google Map Web app:

First define a function to call the Google Map Web app via URL and parameters.

public function integer of_gmweb_direction (string as_saddr, string as_daddr , string as_dirmode);

// as_dirmode:d,t,b,w

string ls_url, ls_as_dirmode4web
inet l_inet
integer li_re

ls_url = "https://maps.google.com/maps?saddr="+as_saddr+"&daddr="+as_daddr+"&dirflag="+ls_as_dirmode4web

l_inet = create inet
li_re = l_inet.hyperlinktourl(ls_url )
Destroy l_inet
return li_re
end function

Call the function by passing in the start address, destination address, and direction mode. For example,

  • The address can either be the name of places (using + as separator) or the latitude and longitude.

  • The direction mode can be: d (for driving), t (for transit), b (for bicycling), w (for walking).

of_ gmweb _direction("22.549721,113.948371","22.5584634,114.1337181","b")

Or

of_ gmweb _direction("appeon+sz+Guangdong+china","22.5584634,114.1337181","d")