Skip to content

Commit

Permalink
refactor(example): update with new gestion of Style
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff authored and gchoqueux committed Jul 11, 2023
1 parent d26f29e commit 955722c
Show file tree
Hide file tree
Showing 21 changed files with 57 additions and 58 deletions.
4 changes: 2 additions & 2 deletions examples/js/plugins/DragNDrop.js
Expand Up @@ -106,12 +106,12 @@ const DragNDrop = (function _() {
layer = new itowns.FeatureGeometryLayer(
file.name,
{
style: new itowns.Style({
style: {
fill: {
color: 'red',
extrusion_height: 200,
},
}),
},
source: source,
opacity: 0.7,
});
Expand Down
4 changes: 2 additions & 2 deletions examples/misc_custom_label.html
Expand Up @@ -109,9 +109,9 @@
const layer = new itowns.LabelLayer('idLabelLayer', {
source: source,
domElement: setLabelContent,
style: new itowns.Style({
style: {
text: { anchor: [-0.8, -1] },
}),
},
});

view.addLayer(layer);
Expand Down
12 changes: 6 additions & 6 deletions examples/misc_instancing.html
Expand Up @@ -118,12 +118,12 @@
source: buildingsSource,
zoom: { min: 15 },
accurate: false,
style: new itowns.Style({
style: {
fill: {
base_altitude: () => 0,
extrusion_height: (p) => p.hauteur || 0,
},
}),
},
});

// Add the FeatureGeometryLayer to the scene and to the debug menu.
Expand Down Expand Up @@ -157,13 +157,13 @@
gltf.scene.position.z = 2;
model.scale.set(6, 6, 6);

var styleModel3D = new itowns.Style({
var styleModel3D = {
point: {
model: {
object: model,
},
},
});
};

var lightsLayer = new itowns.FeatureGeometryLayer(
"lights",
Expand Down Expand Up @@ -192,13 +192,13 @@
);

//Tree
var styleModel3D = new itowns.Style({
var styleModel3D = {
point: {
model: {
object: makeTree(),
},
},
});
};

var treesSource = new itowns.FileSource({
url: "https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/geojson/arbres_bordeaux.geojson",
Expand Down
4 changes: 2 additions & 2 deletions examples/plugins_vrt.html
Expand Up @@ -57,7 +57,7 @@

var velibLayer = new itowns.ColorLayer('velib', {
source: velibSource,
style: new itowns.Style({
style: {
zoom: { min: 10, max: 20 },
point: {
color: 'cyan',
Expand All @@ -69,7 +69,7 @@
haloColor: 'white',
haloWidth: 1,
},
}),
},
addLabelLayer: true,
});

Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_from_fetched_data.html
Expand Up @@ -70,9 +70,9 @@

view.addLayer(new itowns.ColorLayer('Roads', {
source: sourceFromFetchedData,
style: new itowns.Style({
style: {
stroke: { color: 'yellow' },
}),
},
})).then(debugMenu.addLayerGUI.bind(debugMenu));
});

Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_from_format.html
Expand Up @@ -63,10 +63,10 @@

view.addLayer(new itowns.ColorLayer('Urban Area', {
source: sourceFromFormat,
style: new itowns.Style({
style: {
fill: { color: 'red', opacity: 0.5 },
stroke: { color: 'red' },
}),
},
})).then(debugMenu.addLayerGUI.bind(debugMenu));


Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_from_methods.html
Expand Up @@ -65,10 +65,10 @@

view.addLayer(new itowns.ColorLayer('Hydro', {
source: sourceFromFetcherAndParser,
style: new itowns.Style({
style: {
fill: { color: 'cyan', opacity: 0.5 },
stroke: { color: 'blue',},
}),
},
})).then(debugMenu.addLayerGUI.bind(debugMenu));


Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_from_parsed_data.html
Expand Up @@ -82,9 +82,9 @@

view.addLayer(new itowns.ColorLayer('Trains', {
source: sourceFromParsedData,
style: new itowns.Style({
style: {
stroke: { color: 'black', width: 2 },
}),
},
})).then(debugMenu.addLayerGUI.bind(debugMenu));
});

Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_geojson_3d.html
Expand Up @@ -57,12 +57,12 @@
transparent: true,
opacity: 0.7,
zoom: { min: 10 },
style: new itowns.Style({
style: {
fill: {
color: new itowns.THREE.Color(0xbbffbb),
extrusion_height: 80,
}
})
}
});

view.addLayer(marne).then(function menu(layer) {
Expand Down
9 changes: 4 additions & 5 deletions examples/source_file_geojson_raster.html
Expand Up @@ -71,20 +71,19 @@
name: 'ariege',
transparent: true,
source: ariegeSource,
style: new itowns.Style({
style: {
fill: {
color: 'orange',
opacity: 0.5,
},
stroke: {
color: 'white',
},
}),
},
});
// Add the Ariege ColorLayer to the view and grant it a tooltip
view.addLayer(ariegeLayer).then(FeatureToolTip.addLayer);


// Declare the source for the data on Pyrenees Orientales area
const pyoSource = new itowns.FileSource({
url: 'https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements/66-pyrenees-orientales/departement-66-pyrenees-orientales.geojson',
Expand All @@ -96,15 +95,15 @@
name: 'pyrenees-orientales',
transparent: true,
source: pyoSource,
style: new itowns.Style({
style: {
fill: {
pattern: 'images/cross.png',
opacity: 0.8,
},
stroke: {
color:'IndianRed',
},
}),
},
});
// Add The Pyrennees Orientales ColorLayer to the view and grant it a tooltip
view.addLayer(pyoLayer).then(FeatureToolTip.addLayer);
Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_geojson_raster_2.html
Expand Up @@ -89,7 +89,7 @@
// Create a ColorLayer with the earthquake information
const earthquakeLayer = new itowns.ColorLayer('earthquakes', {
source: earthquakeSource,
style: new itowns.Style({
style: {
point: {
color: function (p) { return p.alert; },
radius: function (p) { return p.mag; },
Expand All @@ -103,7 +103,7 @@
anchor: 'bottom',
offset: offset,
},
}),
},
addLabelLayer: true,
});

Expand Down
6 changes: 3 additions & 3 deletions examples/source_file_gpx_3d.html
Expand Up @@ -72,18 +72,18 @@
out: {
crs: view.referenceCrs,
structure: '3d',
style: new itowns.Style({
style: {
stroke : {
color: 'red',
width: 2,
},
point : {
color: 'white',
}
})
}
}
}))
.then(itowns.Feature2Mesh.convert())
.then(itowns.Feature2Mesh.convert({style}))
.then(function (mesh) {
if (mesh) {
mesh.updateMatrixWorld();
Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_gpx_raster.html
Expand Up @@ -64,7 +64,7 @@
format: 'application/gpx',
});

const gpxStyle = new itowns.Style({
const gpxStyle = {
zoom: { min: 9 },
stroke: { color: 'red' },
point: {
Expand All @@ -78,7 +78,7 @@
haloColor: 'white',
haloWidth: 1,
},
});
};

const gpxLayer = new itowns.ColorLayer('Gpx', {
source: gpxSource,
Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_kml_raster.html
Expand Up @@ -63,7 +63,7 @@
format: 'application/kml',
});

var kmlStyle = new itowns.Style({
var kmlStyle = {
zoom: { min: 10, max: 20 },
text: {
field: '{name}',
Expand All @@ -74,7 +74,7 @@
icon: {
anchor: 'bottom',
},
});
};

var kmlLayer = new itowns.ColorLayer('Kml', {
source: kmlSource,
Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_kml_raster_usgs.html
Expand Up @@ -68,7 +68,7 @@
return [ 0, -0.5 * scaleIcon * sizeIcon ];
}

var kmlStyle = new itowns.Style({
var kmlStyle = {
zoom: { min: 10, max: 20 },
text: {
field: '{name}',
Expand All @@ -78,7 +78,7 @@
offset: offset,
anchor: 'bottom',
},
});
};

var kmlLayer = new itowns.ColorLayer('Kml', {
source: kmlSource,
Expand Down
4 changes: 2 additions & 2 deletions examples/source_file_shapefile.html
Expand Up @@ -69,7 +69,7 @@

return view.addLayer(new itowns.ColorLayer('velib', {
source: velibSource,
style: new itowns.Style({
style: {
zoom: { min: 10, max: 20 },
point: { color: 'white', line: 'green' },
text: {
Expand All @@ -79,7 +79,7 @@
haloWidth: 1,
font: ['monospace'],
}
}),
},
addLabelLayer: true,
}));
}).then((layer => {
Expand Down
12 changes: 6 additions & 6 deletions examples/source_stream_wfs_25d.html
Expand Up @@ -152,12 +152,12 @@
source: lyonTclBusSource,
zoom: { min: 2 },

style: new itowns.Style({
style: {
stroke: {
base_altitude: altitudeLine,
width: 5,
}
})
}
});

view.addLayer(lyonTclBusLayer);
Expand Down Expand Up @@ -236,13 +236,13 @@
source: wfsBuildingSource,
zoom: { min: 4 },

style: new itowns.Style({
style: {
fill: {
color: colorBuildings,
base_altitude: altitudeBuildings,
extrusion_height: extrudeBuildings,
}
})
}
});

view.addLayer(wfsBuildingLayer);
Expand All @@ -256,7 +256,7 @@
format: 'application/json',
});

var wfsCartoStyle = new itowns.Style({
var wfsCartoStyle = {
zoom: { min: 0, max: 20 },
text: {
field: '{toponyme}',
Expand All @@ -266,7 +266,7 @@
haloColor: 'rgba(20,20,20, 0.8)',
haloWidth: 3,
},
});
};

var wfsCartoLayer = new itowns.LabelLayer('wfsCarto', {
source: wfsCartoSource,
Expand Down
8 changes: 4 additions & 4 deletions examples/source_stream_wfs_3d.html
Expand Up @@ -116,13 +116,13 @@
source: lyonTclBusSource,
zoom: { min: 9 },

style: new itowns.Style({
style: {
stroke: {
color: colorLine,
base_altitude: altitudeLine,
width: 5,
}
})
}
});
view.addLayer(lyonTclBusLayer);

Expand Down Expand Up @@ -200,13 +200,13 @@
source: wfsBuildingSource,
zoom: { min: 14 },

style: new itowns.Style({
style: {
fill: {
color: colorBuildings,
base_altitude: altitudeBuildings,
extrusion_height: extrudeBuildings,
}
})
}
});
view.addLayer(wfsBuildingLayer);

Expand Down

0 comments on commit 955722c

Please sign in to comment.