iOS Code Snippet ios Map caller(for Chinese)

B4X:
'class name clsMapCaller
'http://www.jianshu.com/p/e4039b5a1a43
' do not forgot add this three line to you main module
'#QueriesSchemes:baidumap
'#QueriesSchemes:iosamap
'#QueriesSchemes:qqmap
Sub Class_Globals
    Type mappoint(title As String,lat As Double,lng As Double,text As String,id As Int)
    Private mapType As Int=0
    Public appname As String
End Sub

'0=auto(default) 1=amap 2=qqmap 3=baidumap
Public Sub Initialize(whichMap As Int)
    mapType=whichMap
End Sub
'single
Public Sub showMarker(mp As mappoint)
    Select mapType
    Case 0
        If checkAMap Then
            markerAMap(mp)
        else if checkQQMap Then
            markerQQMap(mp)
        Else if checkBDMap Then
            markerBDMap(mp)
        Else
            comm.TL("当前设备没有安装主流第三方地图")
        End If
    Case 1
            If checkAMap Then
                markerAMap(mp)
            Else
                comm.TL("当前设备没有安装高德地图")
            End If
    Case 2
            If checkQQMap Then
                markerQQMap(mp)
            Else
                comm.TL("当前设备没有安装QQ地图")
            End If
    Case 3
            If checkBDMap Then
                markerBDMap(mp)
            Else
                comm.TL("当前设备没有安装百度地图")
            End If
    End Select
End Sub
'mappoint list
Public Sub showMarker2(lst As List)
  
End Sub

Private Sub checkAMap As Boolean
    Return Main.App.CanOpenURL("iosamap://")
End Sub
Private Sub markerAMap(mp As mappoint)
    Main.App.OpenURL($"iosamap://viewMap?sourceApplication=${appname}&poiname=${mp.title}&lat=${mp.lat}&lon=${mp.lng}&dev=0"$)
End Sub
Private Sub checkBDMap As Boolean
    Return Main.App.CanOpenURL("baidumap://")
End Sub
Private Sub markerBDMap(mp As mappoint)
    Main.App.OpenURL($"baidumap://map/marker?location=${mp.lat},${mp.lng}&title=${mp.title}&content=${mp.text}"$)
End Sub
Private Sub checkQQMap As Boolean
    Return Main.App.CanOpenURL("qqmap://")
End Sub
Private Sub markerQQMap(mp As mappoint)
    Main.App.OpenURL($"qqmap://map/marker?marker=coord:${mp.lat},${mp.lng};title:${mp.title};addr:${mp.text}&referer=${appname}"$)
End Sub
 

Similar Threads

D
  • Question
iOS Question Maps SDK for iOS v2.6
Replies
5
Views
380
Deleted member 103
D
Replies
5
Views
411
Top