IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

APIs Google Discussion :

Réalisation de constructeur [Google Maps]


Sujet :

APIs Google

  1. #1
    Membre éprouvé

    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    981
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 981
    Points : 1 028
    Points
    1 028
    Billets dans le blog
    36
    Par défaut Réalisation de constructeur
    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
    Mal nommer un objet, c'est ajouter au malheur de ce monde, car le mensonge est justement la grande misère humaine, c'est pourquoi la grande tâche humaine correspondante sera de ne pas servir le mensonge
    Poésie 44, n° 17 - Albert Camus

    Mes réponses vous ont aidés, un clic sur leur pouce vert
    Bonjour chez vous

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    16 959
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 16 959
    Points : 44 122
    Points
    44 122
    Par défaut
    Bonjour,
    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)
    attention à la casse
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    var mapDiv = document.getElementById('map');
    et dans le html
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <div id="Map"></div>
    Pour le reste j'ai du mal à voir ce que tu cherches à faire.

  3. #3
    Membre éprouvé

    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    981
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 981
    Points : 1 028
    Points
    1 028
    Billets dans le blog
    36
    Par défaut
    NoSmoking,

    Encore un immense merci pour cet aide aux effets aspro effervescent 1000 . Du coup ça résout deux posts dont celui sur le constructeur qui doit paraître surréaliste pour les experts!

    Je suis vraiment un pour faire une faute pareille

    Maintenant mon exemple d'infoWindo avec 2 onglets dont un streetView fonctionne parfaitement sur http://monhost.hol.es/infoWindow/Geo...kersList2.html

    Mais ce même code génère les message d'erreur ci-dessus dans l'objet ActiveX webBrowser Ms Access. Ça reste toujours un mystère.

    Merci encore pour le temps que tu m'as consacré.

    Bonjour chez toi
    Mal nommer un objet, c'est ajouter au malheur de ce monde, car le mensonge est justement la grande misère humaine, c'est pourquoi la grande tâche humaine correspondante sera de ne pas servir le mensonge
    Poésie 44, n° 17 - Albert Camus

    Mes réponses vous ont aidés, un clic sur leur pouce vert
    Bonjour chez vous

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. problème de constructeur avec wxWidget
    Par Ardeciel dans le forum wxWidgets
    Réponses: 2
    Dernier message: 10/03/2007, 23h11
  2. Problème définition constructeur
    Par bugland dans le forum Langage
    Réponses: 11
    Dernier message: 12/02/2007, 14h34
  3. Problème de constructeur de copie ?
    Par Bestiol dans le forum C++
    Réponses: 6
    Dernier message: 03/11/2006, 11h28
  4. [POO]Probléme de constructeur virtuel surchargé
    Par Laurent Dardenne dans le forum Delphi
    Réponses: 10
    Dernier message: 15/08/2006, 12h19
  5. [C#] DLL, problème de constructeur
    Par gmonta dans le forum C#
    Réponses: 4
    Dernier message: 30/11/2005, 09h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo