Bonjour,

J'utilise les bases de cette contribution de Philben pour afficher des points dans Google Maps.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Case "frmMenuGeneral"
 
        Me.ctlNavigateur.Navigate CurrentProject.Path & "\Système\" & strNomPage
 
        strSql = "SELECT tblCommunes.CommuneNom, tblCommunes.CommuneLat, tblCommunes.CommuneLong, Count(tblLogements.LogImm) AS CompteDeLogImm " & _
                 "FROM (tblCommunes INNER JOIN tblImmeubles ON tblCommunes.CommuneId = tblImmeubles.ImmNumeroCommune) INNER JOIN tblLogements " & _
                 "ON tblImmeubles.ImmId = tblLogements.LogImm GROUP BY tblCommunes.CommuneNom, tblCommunes.CommuneLat, tblCommunes.CommuneLong " & _
                 "ORDER BY tblCommunes.CommuneNom;"
 
        Set db = CurrentDb
        Set rst = db.OpenRecordset(strSql)
 
        If rst.BOF Then
 
            MsgBox "il n'y a pas d'enregistrements"
 
            GoTo Exit_Sub
 
        End If
 
        Do Until rst.EOF
 
            dblLat = rst("CommuneLat")
            dblLong = rst("CommuneLong")
 
            strLigne1 = rst("CommuneNom")
            strLigne2 = rst("CompteDeLogImm") & " logements"
 
            Do
 
            DoEvents
 
            Loop While Me.ctlNavigateur.busy
 
            AddPoint dblLat, dblLong, 10, "" & strLigne1 & ",<br> " & strLigne2 & ""
 
            rst.MoveNext
 
        Loop
Procédure AddPoint :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
'Ajoute un point GPS dans Google map. Si zoom = 0 la carte n'est pas centrée
Private Sub AddPoint(ByVal dblLat As Double, ByVal dblLong As Double, _
                     Optional ByVal bytZoom As Byte = 0, _
                     Optional ByVal strMessage As String)
 
    'Déclaration de la variable
    Dim strScript As String
 
    strScript = "affMsg(" & str(dblLat) & "," & str(dblLong) & "," & bytZoom & ",'" & strMessage & "');"
 
    Me.ctlNavigateur.Document.parentWindow.execScript strScript, "JScript"
 
End Sub
Cela fonctionne, mis à part le fait que si la variable strMessage contient des <'>, j'ai une erreur (voir pièce jointe):

J'ai essayé de doubler mes quotes ou d'encadrer ma variable avec Chr(34), mais cela ne fonctionne pas.

Pour l'instant, j'ai remplacé les <'> par des espaces avec Replace(), mais c'est à moitié satisfaisant.

Si quelqu'un a déjà résolu ce problème...

Merci d'avance.

Domi2