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

IGN API Géoportail Discussion :

Migration version 2 - Autre problème


Sujet :

IGN API Géoportail

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut Migration version 2 - Autre problème
    Malgré la consultation du forum et de la doc je n'arrive pas à migrer de la 1.3 à la 2.0 (mais je ne suis pas un expert).
    Besoin d'aide
    Message : "Uncaught TypeError: Cannot read property 'defaultCRS' of undefined"
    Code de la page :
    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
    <!DOCTYPE html>
    <html lang="fr">
    <html>
    <head>
    	<meta charset="utf-8">
    	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    	<title>Territoire passé en argument</title>
    	<style type="text/css">
    		<!--/*--><![CDATA[/*><!--*/
    		html {width:100%; height:100%;}
    		body {margin:0; padding:0; overflow:hidden; width:100%; height:100%; background:#0ff;}
    		/*]]>*/-->
    	</style>
    </head>
    <body>
    	<div id="viewerDiv" style="width:100%; height:100%;"></div>
    
       <!-- Application script -->
        <script type="text/javascript">
    		<!--//--><![CDATA[//><!--
    
    		// Lecture paramètre territoire
    		var query = window.location.search.substring(1);
    		switch (query) {
    			case 'FXX':		// Métropole
    				var Latitude = 46.7;
    				var Longitude = 3.043;
    				var Echelle = 6;
    			break;
    			case 'CRZ':		// Crozet
    				var Latitude = -46.41;
    				var Longitude = 51.75;
    				var Echelle = 10;
    			break;
    			case 'KER':		// Kergelen
    				var Latitude = -49.39;
    				var Longitude = 69.34;
    				var Echelle = 9;
    			break;
    			case 'GLP':		// Guadeloupe
    				var Latitude = 16.205;
    				var Longitude = -61.4893;
    				var Echelle = 10;
    			break;	
    			case 'GUF':		// Guyane
    				var Latitude = 3.93;
    				var Longitude = -53.123;
    				var Echelle = 8;
    			break;
    			case 'MTQ':		// Martinique
    				var Latitude = 14.64;
    				var Longitude = -61.02;
    				var Echelle = 10;
    			break;
    			case 'REU':		// Réunion
    				var Latitude = -21.13;
    				var Longitude = 55.528;
    				var Echelle = 10;
    			break;		
    			case 'MYT':		// Mayotte
    				var Latitude = -12.83;
    				var Longitude = 45.16;
    				var Echelle = 11;
    			break;
    			case 'NCL':		// Nouvelle Caledonie
    				var Latitude = -21.42;
    				var Longitude = 165.26;
    				var Echelle = 8;
    			break;
    			case 'PYF':		// Polynésie Française
    				var Latitude = -17.65;
    				var Longitude = -149.47;
    				var Echelle = 10;
    			break;					
    			case 'SBA':		// Saint Barthélémy
    				var Latitude = 17.9;
    				var Longitude = -62.84;
    				var Echelle = 12;
    			break;
    			case 'SMA':		// Saint Martin
    				var Latitude = 18.05;
    				var Longitude = -63.06;
    				var Echelle = 11;
    			break;		
    			case 'SPM':		// Saint Pierre et Miquelon
    				var Latitude = 46.943;
    				var Longitude = -56.3;
    				var Echelle = 10;
    			break;					
    			case 'WLF':		// Wallis et Futuna
    				var Latitude = -13.275;
    				var Longitude = -176.2;
    				var Echelle = 12;
    			break;				
    			default:
    				alert ("Zone géographique non traitée");
    			break;
    		}		
    		
    		var viewer= null;									//viewer instance
    		if (window.__Geoportal$timer===undefined) {
    			var __Geoportal$timer= null;
    		}
    
    		// onload event will call myOnLoad :
    		function myOnLoad() {
    			if (__Geoportal$timer!=null) {
    				window.clearTimeout(__Geoportal$timer);
    				__Geoportal$timer= null;
    			}
    			var f;
    			var C= ['OpenLayers', 'Geoportal', 'Geoportal.Viewer', 'Geoportal.Viewer.Default'];
    			for (var i= 0, l= C.length; i<l; i++) {
    				try {
    					f= eval(C[i]);
    				} catch (e) {
    					f= undefined;
    				}
    				if (typeof(f)==='undefined') {
    					__Geoportal$timer= window.setTimeout('myOnLoad();', 300);
    					return;
    				}
    			}
    			
    			// build a new viewer :
    			viewer= new Geoportal.Viewer.Default(			// 'Default' viewer (on peut utiliser 'Simple' 'Standard')
    					"viewerDiv",							// id du 'div' d'affichage de la carte
    					OpenLayers.Util.extend({				// viewer parametres :
    						//mode:'normal',					// default value
    						//territory:query,					// Territoire
    						//projection:'IGNF:GEOPORTALFXX',	// default value
    						//displayProjection:'IGNF:RGF93G',	// default value is 'CRS:84'
    						proxy:'proxy.php?url=',				// Si nécessaire (recherche, KML, etc ... données sur un autre serveur)
    						nameInstance:'viewer'},
    						// variable contenant la configuration des clefs API remplie par <Geoportal.GeoRMHandler.getConfig>
    						window.gGEOPORTALRIGHTSMANAGEMENT===undefined? {'apiKey':'ulbdujridm80lfks2x6gtzk2'} : gGEOPORTALRIGHTSMANAGEMENT
    					)
    			);
    			if (viewer){
    				viewer.addGeoportalLayers(['ORTHOIMAGERY.ORTHOPHOTOS'], {'ORTHOIMAGERY.ORTHOPHOTOS':{visibility:false,opacity:1}});
    				viewer.addGeoportalLayers(['GEOGRAPHICALGRIDSYSTEMS.MAPS'], {'GEOGRAPHICALGRIDSYSTEMS.MAPS':{visibility:true,opacity:1}});
    
    				// Ajout de fonctions dans les menus
    				var tbx= viewer.getMap().getControlsByClass('Geoportal.Control.ToolBox')[0];
    				// Ajout barre mesures
    				var measurebar= new Geoportal.Control.MeasureToolbar({
    					div: OpenLayers.Util.getElement(tbx.id+'_measure'),
    					displaySystem: (viewer.getMap().getProjection().getProjName()=='longlat'? 'geographic' :' metric'),
    					targetElement: OpenLayers.Util.getElement(tbx.id+'_meares')
    				});
    				viewer.getMap().addControl(measurebar);
    				//ajout barre de recherche
    				searchControl = new Geoportal.Control.SearchToolbar({
    					div: OpenLayers.Util.getElement(tbx.id + '_search'),
    					geonamesOptions: {setZoom: Geoportal.Control.LocationUtilityService.GeoNames.setZoomForBDNyme, layerOptions: { name: 'TOPONYMS.ALL:OPENLS', formatOptions: {version: '1.0'}}},
    					geocodeOptions: {layerOptions: {name: 'ADDRESSES.CROSSINGS:OPENLS', formatOptions: {version:'1.0'}}}
    				});
    				viewer.getMap().addControl(searchControl);
    				//ajout d'une couche Layer
    				var addLbar= new Geoportal.Control.LayerToolbar({
    					div: OpenLayers.Util.getElement(tbx.id+'_addlyr'),
    					// Geoportal.Control.AddVectorLayer options
    					addVectorLayerOptions: {
    						supportedClasses: [
    						'OpenLayers.Geometry.Point',
    						'OpenLayers.Geometry.LineString',
    						'OpenLayers.Geometry.Polygon',
    						'OpenLayers.Format.KML',
    						'Geoportal.Format.GPX',
    						'OpenLayers.Format.OSM'],
    						// OpenLayers.Layer.Vector options
    						drawFeatureOptions: {},
    						dragFeatureOptions: {},
    						modifyFeatureOptions: {},
    						deleteFeatureOptions: {},
    						selectFeatureOptions: {},
    						editingToolbarOptions: {}
    					}
    				});
    				viewer.getMap().addControl(addLbar);
    				//ajout de l'outil d'impression
    				var nv= viewer.getMap().getControlsByClass('Geoportal.Control.NavToolbar')[0];
    				nv.addControls([new Geoportal.Control.PrintMap()]);
    
    				// Ajout KML
    				viewer.getMap().addLayer("KML", "Coderando", "kml/Coderando.kml", {visibility:false});				
    				// Affichage carte avec valeur zoom	
    				viewer.getMap().setCenterAtLonLat(parseFloat(Longitude), parseFloat(Latitude), Echelle);
    			}
    			else {
    				alert('Echec chargement visualisateur');
    				return;			
    			}
    		}
    
    		window.onload= myOnLoad;							// call myOnLoad when onload event is fired
    		//--><!]]>
    	</script>
        <!-- TELECHARGER l'API en fonction des besoins
    		<script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/VERSION/GeoportalMin.js"></script>
    		<script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/VERSION/Geoportal.js"></script>
    		<script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/VERSION/GeoportalExtended.js"></script>
        -->
        <script type="text/javascript" src="http://api.ign.fr/geoportail/api/js/2.0.0/GeoportalExtended.js"></script>
    </body>
    </html>

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2010
    Messages
    442
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 442
    Points : 502
    Points
    502
    Par défaut
    L'API 1.3 fait appel aux services du Géoportail 2, il faut avoir une clé antérieure au 25 juin 2012.
    L'API 2.0.0 fait appel aux services du Géoportail 3, toutes les clés sont valides.

    Avec le Géoportail 3
    • il n'y pas pas de WMSC mais du WMTS
    • il n'y a qu'une seule projection pour l'ensemble; que du web mercator, pas de FXX ou de ANT


    Dans ton code, il faut
    • remplacer "1.3" par "2.0.0"
    • le nom des couches ne doit pas avoir "truc.bidule:WMSC" mais seulement "truc.bidule"
    • "teritories=FXX" n'a plus d'utilité


    La page du blog peut aider http://api.ign.fr/article/146/passage-a-l-api-200

    Sinon, il y a

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut
    Merci pour ta réponse mais j'avais bien :
    - remplacé 1.3 par 2.0.0 (en prenant une nouvelle clé API car j'ai vu que cela ne fonctionnait pas avec les anciennes)
    - supprimé WMSC dans le nom des couches
    - pas utilisé "territories=FXX" (mais si on veut une carte de la Réunion il faut bien donner une valeur mais on verra après!).

    Bref j'avais modifié comme demandé par le mail d'info mais quelque chose m'échappe...

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    2 124
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 2 124
    Points : 1 764
    Points
    1 764
    Par défaut
    C'est beaucoup plus facile de trouver les erreurs avec une page d'essai accessible en ligne ....

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut
    Citation Envoyé par mga_geo Voir le message
    C'est beaucoup plus facile de trouver les erreurs avec une page d'essai accessible en ligne ....
    Je ne comprend pas cette remarque...
    Quel rapport avec le problème?

  6. #6
    Membre averti Avatar de Zébulon-21
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    392
    Détails du profil
    Informations personnelles :
    Localisation : France, Côte d'Or (Bourgogne)

    Informations forums :
    Inscription : Mai 2009
    Messages : 392
    Points : 315
    Points
    315
    Par défaut
    Citation Envoyé par dung25 Voir le message
    Je ne comprend pas cette remarque...
    Quel rapport avec le problème?
    Sans doute veut-il dire que c'est mieux d'avoir un lien qui lui permette de lire le code source, d'analyser avec Firebug, etc...

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut Info complémentaires
    J'ai constaté que le problème gravitait autour de la déclaration de la clé API

    La version 1.3 qui fonctionne :
    http://chatenois.ecole.free.fr/ign/Version1-3.html
    Clé API déclarée via : "<script type="text/javascript" src="http://api.ign.fr/geoportail/api?key=XXXXXX&includeEngine=false&"></script>

    Version 1.3 modifiée (bis)
    http://chatenois.ecole.free.fr/ign/Version1-3bis.html
    La fenêtre, les menus et le kml s'affichent mais pas les cartes et les photos (pas de message d'erreur)
    Clé API déclarée via : "window.gGEOPORTALRIGHTSMANAGEMENT===undefined? {'apiKey':'XXXXX'} : gGEOPORTALRIGHTSMANAGEMENT"

    Version 2.0 à partir de 1.3 modifié (remplacement de "1.3" par "2.0.0" nom des couches sans :WMSC", changement clé pour 2.0.0)
    http://chatenois.ecole.free.fr/ign/Version2-0.html
    Rien ne s'affiche. Message :
    Uncaught TypeError: Cannot read property 'defaultCRS' of undefined GeoportalExtended.js:138
    Geoportal.Catalogue.getTerritory GeoportalExtended.js:138
    Geoportal.Viewer.OpenLayers.Class._initMap GeoportalExtended.js:138
    Geoportal.Viewer.OpenLayers.Class._setOptions GeoportalExtended.js:138
    Geoportal.Viewer.OpenLayers.Class.initialize GeoportalExtended.js:138
    Geoportal.Viewer.Default.OpenLayers.Class.initialize GeoportalExtended.js:138
    myOnLoad

    J'espère que ces infos complémentaires permettrons de trouver une solution (cela dépasse mon niveau de connaissance)
    J'ai cru lire que les nouvelles clés (mais j'ai tellement lu!) fonctionnaient avec les anciennes versions 1.3 : ce n'est pas le cas.

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Février 2010
    Messages
    442
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 442
    Points : 502
    Points
    502
    Par défaut
    Citation Envoyé par dung25 Voir le message
    J'ai cru lire que les nouvelles clés (mais j'ai tellement lu!) fonctionnaient avec les anciennes versions 1.3 : ce n'est pas le cas.
    tu confonds version de l'API JavaScript et version du service Géoportail.
    http://www.developpez.net/forums/d12...a/#post6871329

  9. #9
    Membre chevronné
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    2 124
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 2 124
    Points : 1 764
    Points
    1 764
    Par défaut
    Perso, j'utilise une autre des méthodes de chargement de l'api que je trouve plus lisible.

    Cela donne par exemple: http://mga.alwaysdata.net/geoportail...chatenois.html

  10. #10
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut Problème soldé
    Merci beaucoup pour ton aide.
    C'est très sympa de ta part.

  11. #11
    Nouveau membre du Club
    Homme Profil pro
    retraité
    Inscrit en
    Janvier 2012
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2012
    Messages : 31
    Points : 29
    Points
    29
    Par défaut Problème soldé
    Suite. J'ai oublier de citer mon "sauveur" : MGA_GEO

  12. #12
    Expert confirmé
    Homme Profil pro
    Ingénieur cartographe
    Inscrit en
    Avril 2009
    Messages
    3 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur cartographe
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 173
    Points : 4 224
    Points
    4 224
    Par défaut
    Si le problème est résolu (le mettre ) sinon tes URLs ne fonctionnent pas

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

Discussions similaires

  1. Icones : tailles et autres problèmes
    Par Yepazix dans le forum Windows XP
    Réponses: 9
    Dernier message: 05/03/2007, 16h07
  2. 1016 can't open file "table.MYI" (errno: 132) et autre problème
    Par epeichette dans le forum Installation
    Réponses: 4
    Dernier message: 08/02/2007, 14h15
  3. Migration version 3.23 vers supérieure
    Par besoin_info dans le forum Administration
    Réponses: 5
    Dernier message: 27/02/2006, 20h17
  4. [version 8.1] problème de delete massif
    Par XPierrot dans le forum DB2
    Réponses: 6
    Dernier message: 12/01/2006, 16h01

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