Bonjour à tous,

Voilà j'ai besoin d'aide sur hélas les bases de JavaScript et de l'appel du constructeur, enfin je crois. Je ne comprends pas pourquoi le code sous l'objet ActiveX webBrowser Access et directement dans un browser, le comportement est différent:

Soit le code JS suivant dans le fichier HTML : Geocoding_markersList2.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!-- saved from url=(0016)<a href="http://localhost" target="_blank">http://localhost</a> -->
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow:hidden;">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Map</title>
<link href = "http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css " rel = "stylesheet" type="text/css"/>
<script type="text/javascript" src = "http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src = "http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script language="javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3"></script>
<script type="text/javascript" src="/utils.js"></script> 
 <script type="text/javascript">
var tMarker = [{
    'type' : "H",
	'locNr': "Location 1",
    'lat': 45.767299,
    'lon': 4.834329,
    'city': 'Lyon',
    'zip': 69,
    'land': "Fance",
    'info': '<b>Lyon<\/b><br>la suite du texte...'
},
{	'type' : "H",
    'locNr': "Location 2",
    'lat': 48.856667,
    'lon': 2.350987,
    'city': 'Paris',
    'zip': 75,
    'land': "Fance",
    'info': '<b>Paris<\/b><br>la suite du texte...'
},
{	'type' : "H",
    'locNr': "Location 3",
    'lat': 44.837368,
    'lon': -0.576144,
    'city': 'Bordeaux',
    'zip': 33,
    'land': "Fance",
    'info': '<b>Bordeaux<\/b><br>la suite du texte...'
},
{	'type' : "H",
    'locNr': "Location 4",
    'lat': 43.297612,
    'lon': 5.381042,
    'city': 'Marseille',
    'zip': 13,
    'land': "Fance",
    'info': '<b>Marseille<\/b><br>la suite du texte...'
}];
 
var oMap = {
    map: null,
    markers: [] 
}
 
oMap.init = function() {
	if (document.getElementById)
	{	var mapDiv = document.getElementById('map');
		var latlng = new google.maps.LatLng(46.316584,2.98169);
		var options = 
		{	zoom: 6,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP, // Existe d'autre format Ex: HYBRID => Plan sur photo
			scalecontrol: true,
			navigationControl: true,
			maxZoom : 20,
			navigationControlOptions:
			{	style: google.maps.NavigationControlStyle.SMALL
			},
			mapTypeControlOptions:
			{	style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
			},
			streetViewControl: true
		};	
    };
	oMap.map = new google.maps.Map(mapDiv, options);	
}
 
oMap.addMarker = function()
{	var type = tMarker[1].type;
	var lat = tMarker[1].lat;
	var lng = tMarker[1].lon;
	var locNr = tMarker[1].locNr;
	var city = tMarker[1].city;
	var zip = tMarker[1].zip;
	var land = tMarker[1].land;
	var msg = tMarker[1].info;
 
	if (oMap.map){
		var latlng = new google.maps.LatLng(lat,lng);
		switch (type){
			case 'H':
				var options = {
					map: oMap.map,
					position: latlng,
					title: msg
				};
				break;
			case 'S':
				var options = {
					map: oMap.map,
					position: latlng,
					icon: "http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|B5FF33|11|b|Salle",
					title: msg
				};
				break;
		};	
		var marker = new google.maps.Marker(options);
		var contentMarker = [
			'<div id="InfoText">', 
				'<div class ="tabs">',	// Si objet class => appel dans JQuery par ".objetName". Ex: $(".tabs").tabs(). si objet id => appel dans JQuery avec "#objetName". Ex: $("#tabs").tabs()
					'<ul>', 
						'<li><a href="#tab1" id="IG">General</a></li>',
						'<li><a href="#tab2" id="SV">Street View</a></li>',
					'</ul>', 
					'<div id="tab1">', 
						'<h3><b>' + options.title + '</h3></b>',
						'<p> Coordonnées GPS : ' + options.position  + '</p>',
					'</div>', 
					'<div id="tab2">',
						'<div id="streetview_canvas"></div>', 
					'</div>',
				'</div>',
			'</div>'
		].join('');
 
		var infowindow = new google.maps.InfoWindow({
			content  : contentMarker,
			position : marker.position //latlng existe aussi ligne 48
		});
 
		google.maps.event.addListener(marker, "click", function () {
        infowindow.open(this.getMap(), this);
		});
 
 
		google.maps.event.addListener(infowindow, 'domready', function () {
			$(".tabs").tabs();
			$('#SV').click(function () {
				//Creates a street view panorama object.
				var streetViewDiv = document.getElementById("streetview_canvas");
				var streetViewOptions = {
					position : marker.position
				};
				var streetView = new google.maps.StreetViewPanorama(streetViewDiv, streetViewOptions);
				oMap.map.setStreetView(streetView);	
			});
		});
 
		oMap.markers.push(marker);
	};
}
 
oMap.clearMarkers = function() {
	if (oMap.map) {
		for (var i in oMap.markers) {
			oMap.markers[i].setMap(null);
		}
		oMap.markers.length = 0;
}}
 
oMap.adjustViewPort = function() {
	if (oMap.map) {
		var bounds = new google.maps.LatLngBounds();
		for (var i in oMap.markers) {
			bounds.extend(oMap.markers[i].getPosition());
		}
		oMap.map.fitBounds(bounds);
}}
 
 
google.maps.event.addDomListener(window,'load', oMap.init); //  --> A désactiver si appel par VBA Access
 
</script>
<style>
body {
	height: 100%;
	margin: 0px; 
	padding: 0px; 
	overflow: hidden 
}
 
#map { 
	height: 100%;
}
 
#infotext {
  font-size:12px;
  width:480px;
  height:380px;
}
 
.tabs {
  width:450px;
  height:350px;
}
#pano {
  width:350px;
  height: 250px;
}
 
#streetview_canvas {
  width:400px;
  height: 340px;
}
 
</style>
</head>
<body>
  <div id="Map"></div>
</body>
</html>

Sous MS Access au chargement de la forme avec l'objet ActiveX webBrowser , il y a le code ci-dessous qui fonctionne et fait apparaître le marker sur la GoogleMaps au problème près de l'erreur non bloquante de script avec aps.googleapis.com/maps-api-v3/api/js/22/14/intl/fr_ALL/util.js] à l'appel du street view:
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
Private Sub Form_Load()
 
    Dim fileName As String, sPath As String
 
    fileName = "\Geocoding_markersList2.html"
    Me.wbGeoLoc.Navigate CurrentProject.Path & fileName
    Do While Me.wbGeoLoc.ReadyState <> acComplete: DoEvents: Loop
 
    sScript = "oMap.init()"
    Me.wbGeoLoc.Document.parentWindow.execScript sScript, csScriptLanguage
 
    sScript = "oMap.addMarker()"
    Me.wbGeoLoc.Document.parentWindow.execScript sScript, csScriptLanguage
 
End Sub
Dans un browser avec l'activation de ligne google.maps.event.addDomListener(window,'load', oMap.init); , je n'obtiens rien dans le browser voir http://monhost.hol.es/infoWindow/Geo...kersList2.html)

J'ai l'intuition que cela est dû à l'appel de constructeur car si j'ai a peu près compris une déclaration
objet.methode = function(){}
est celle d'un constructeur alors que si j'utilise des fonctions ça fonctionne parfaitement voir http://monhost.hol.es/infoWindow/streetView.html