Bonjour,
je ne comprend pas l'interet de 'new' ,
ces deux codes sont exactement pareil non?
code1:
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <DIV id="carte" style="width:30%; height:30%"></div> <SCRIPT> //fond OSM var osm=new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' } ); var map=new L.map('carte',{ center:[46.85, 2.3518], zoom:4, layers:[osm] }); </SCRIPT><BR>
code2:
du coup quel est l'avantage de l'un ou de l'autre?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 var map=L.map('carte').setView([46.85, 2.3518],4); var osm=L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'} ).addTo(map);
Merci d'avance pour votre aide
Partager