diff --git a/web/src/beta/features/PluginPlayground/Plugins/presets/common.ts b/web/src/beta/features/PluginPlayground/Plugins/presets/common.ts index 71cdaad6b..469b2a82d 100644 --- a/web/src/beta/features/PluginPlayground/Plugins/presets/common.ts +++ b/web/src/beta/features/PluginPlayground/Plugins/presets/common.ts @@ -1,4 +1,5 @@ export const PRESET_PLUGIN_COMMON_STYLE = ` +
+

Filter Cities based on Population:

+
+ + + +
+
+ + +\`); + + + +// Define a geojson point data +const samplePointData = { + type: "simple", + data: { + type: "geojson", + // URL of GeoJSON file + url: "https://reearth.github.io/visualizer-plugin-sample-data/public/geojson/sample_population_marker.geojson" + + }, + marker: {}, +}; + +// Add the layer to Re:Earth +const layerId = reearth.layers.add(samplePointData); + +// Move the camera to the specified position +reearth.camera.flyTo( + { + // Define the camera's target position + heading: 6.283185307179586, + height: 2308186.843368756, + lat: -32.389771622286766, + lng: 46.5725045061546, + pitch: -1.0274739891405908, + roll: 6.283185307179586 + }, + { + // Define the duration of the camera movement (in seconds) + duration: 2.0, + } +); + +// Listen for messages from the UI and override the style +reearth.extension.on("message", (msg) => { + const { action } = msg; + if (action === "showAllFeatures") { + reearth.layers.override(layerId, { + marker: { + show: true, + }, + }); + } else if (action === "showFeaturesBelow20000") { + reearth.layers.override(layerId, { + marker: { + show: { + expression: { + conditions: [ + ["\${pop_max} > 20000", "false"], + ["\${pop_max} <= 20000", "true"], + ], + }, + }, + }, + }); + } + else if (action === "showFeaturesAbove20000") { + reearth.layers.override(layerId, { + marker: { + show: { + expression: { + conditions: [ + ["\${pop_max} <= 20000", "false"], + ["\${pop_max} > 20000", "true"], + ], + }, + }, + }, + }); + } +})` +}; + +export const filterFeatureWithStyle: PluginType = { + id: "filter-features-with-style", + title: "Filter Features with Style", + files: [widgetFile, yamlFile] +};