Skip to content

Commit

Permalink
docs: add example how to use icons in webgl layer
Browse files Browse the repository at this point in the history
closes #274
  • Loading branch information
d-koppenhagen committed Dec 17, 2023
1 parent 27ebc4b commit feb216b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/demos/WebglPointsLayerDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
/>

<ol-tile-layer>
<ol-source-osm />
<ol-source-osm crossOrigin="anonymous" />
</ol-tile-layer>

<ol-webgl-points-layer :styles="webglPointsStyle">
<ol-source-webglpoints
:format="geoJson"
crossOrigin="anonymous"
url="https://openlayers.org/en/latest/examples/data/geojson/world-cities.geojson"
/>
</ol-webgl-points-layer>
Expand Down
22 changes: 7 additions & 15 deletions src/demos/WebglPointsSourceDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
/>

<ol-tile-layer>
<ol-source-osm />
<ol-source-osm crossOrigin="anonymous" />
</ol-tile-layer>

<ol-webgl-points-layer :styles="webglPointsStyle">
<ol-source-webglpoints :format="geoJson">
<ol-source-webglpoints crossOrigin="anonymous" :format="geoJson">
<ol-feature v-for="index in 20" :key="index">
<ol-geom-point
:coordinates="[
Expand All @@ -38,6 +38,7 @@ const center = ref([40, 40]);
const projection = ref("EPSG:4326");
const zoom = ref(5);
const rotation = ref(0);
import marker from "@/assets/marker.png";
const format = inject("ol-format");
const geoJson = new format.GeoJSON();
Expand All @@ -47,18 +48,9 @@ const getRandomInRange = (from, to, fixed) => {
};
const webglPointsStyle = {
"circle-radius": 6,
"circle-fill-color": "yellow",
"circle-stroke-width": 2,
"circle-stroke-color": "darkblue",
"circle-opacity": [
"interpolate",
["linear"],
["get", "population"],
40000,
0.6,
2000000,
0.92,
],
"icon-src": marker,
"icon-width": 20,
"icon-height": 30,
"icon-color": [180, 255, 200],
};
</script>

0 comments on commit feb216b

Please # to comment.