-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,459 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { SidebarPortal } from '@plone/volto/components'; | ||
import InlineForm from '@plone/volto/components/manage/Form/InlineForm'; | ||
import SiteLocationMapView from './View'; | ||
import schema from './schema'; | ||
import { connectBlockToProviderData } from 'volto-datablocks/hocs'; | ||
|
||
const Edit = (props) => { | ||
const { data = {}, block = null, selected = false, onChangeBlock } = props; | ||
|
||
return ( | ||
<> | ||
<SiteLocationMapView {...props} mode="edit" /> | ||
|
||
<SidebarPortal selected={selected}> | ||
<InlineForm | ||
schema={schema} | ||
title={schema.title} | ||
onChangeField={(id, value) => { | ||
onChangeBlock(block, { | ||
...data, | ||
[id]: value, | ||
}); | ||
}} | ||
formData={data} | ||
/> | ||
</SidebarPortal> | ||
</> | ||
); | ||
}; | ||
|
||
export default connectBlockToProviderData(Edit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { useState } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import Map from '@eeacms/volto-openlayers-map/Map'; | ||
import { Interactions } from '@eeacms/volto-openlayers-map/Interactions'; | ||
import { Controls } from '@eeacms/volto-openlayers-map/Controls'; | ||
import { Layers, Layer } from '@eeacms/volto-openlayers-map/Layers'; | ||
import { openlayers } from '@eeacms/volto-openlayers-map'; | ||
import { getSiteLocationURL } from './index'; | ||
import qs from 'querystring'; | ||
import './style.css'; | ||
|
||
const View = (props) => { | ||
const [options, setOptions] = React.useState({}); | ||
const [vectorSource, setVectorSource] = useState(null); | ||
const { format, proj, source, style } = openlayers; | ||
const { siteInspireId } = { ...props.query, ...props.discodata_query }; | ||
|
||
React.useState(() => { | ||
if (__SERVER__) return; | ||
const vs = vectorSource || new source.Vector(); | ||
if (!vectorSource) { | ||
setVectorSource(vs); | ||
} | ||
if (!siteInspireId) return; | ||
const esrijsonFormat = new format.EsriJSON(); | ||
// Get site feature | ||
const url = getSiteLocationURL(siteInspireId); | ||
fetch(url).then(function (response) { | ||
if (response.status !== 200) return; | ||
response.json().then(function (data) { | ||
const features = esrijsonFormat.readFeatures(data); | ||
if (features.length > 0) { | ||
vs.addFeatures(features); | ||
setOptions({ | ||
...options, | ||
extent: features[0].getGeometry().getExtent(), | ||
}); | ||
} | ||
}); | ||
}); | ||
}, [siteInspireId]); | ||
|
||
if (__SERVER__ || !vectorSource) return ''; | ||
|
||
const siteStyle = new style.Style({ | ||
image: new style.Circle({ | ||
radius: 3, | ||
fill: new style.Fill({ color: '#00FF00' }), | ||
stroke: new style.Stroke({ color: '#6A6A6A', width: 1 }), | ||
zIndex: 0, | ||
}), | ||
}); | ||
|
||
return ( | ||
<div className="site-location-map-wrapper full-width"> | ||
<div className="site-location-map full-width"> | ||
<Map | ||
view={{ | ||
center: proj.fromLonLat([20, 50]), | ||
showFullExtent: true, | ||
maxZoom: 12, | ||
minZoom: 12, | ||
zoom: 12, | ||
}} | ||
renderer="webgl" | ||
{...options} | ||
> | ||
<Layers> | ||
<Layer.Tile | ||
source={ | ||
new source.XYZ({ | ||
url: | ||
'https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', | ||
}) | ||
} | ||
zIndex={0} | ||
/> | ||
<Layer.VectorImage | ||
source={vectorSource} | ||
style={siteStyle} | ||
title="1.Sites" | ||
zIndex={1} | ||
/> | ||
</Layers> | ||
<Controls attribution={false} zoom={false} /> | ||
<Interactions | ||
doubleClickZoom={false} | ||
dragAndDrop={false} | ||
dragPan={false} | ||
keyboardPan={false} | ||
keyboardZoom={false} | ||
mouseWheelZoom={false} | ||
pointer={false} | ||
select={false} | ||
/> | ||
</Map> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default connect((state) => ({ | ||
query: qs.parse(state.router.location.search.replace('?', '')), | ||
discodata_query: state.discodata_query.search, | ||
}))(View); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sliderSVG from '@plone/volto/icons/slider.svg'; | ||
import { getEncodedString } from '~/utils'; | ||
import SiteLocationMapEdit from './Edit'; | ||
import SiteLocationMapView from './View'; | ||
|
||
export const getSiteLocationURL = (siteInspireId) => { | ||
const condition = `(InspireSiteId LIKE '${getEncodedString(siteInspireId)}')`; | ||
return `https://air.discomap.eea.europa.eu/arcgis/rest/services/Air/IED_SiteMap/FeatureServer/0/query?f=json&where=${condition}&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=InspireSiteId&outSR=102100`; | ||
}; | ||
|
||
export default (config) => { | ||
config.blocks.blocksConfig.site_location = { | ||
id: 'site_location', | ||
title: 'Site location', | ||
icon: sliderSVG, | ||
group: 'eprtr_blocks', | ||
edit: SiteLocationMapEdit, | ||
view: SiteLocationMapView, | ||
restricted: false, | ||
mostUsed: false, | ||
sidebarTab: 1, | ||
security: { | ||
addPermission: [], | ||
view: [], | ||
}, | ||
}; | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const schema = { | ||
title: 'Site location', | ||
|
||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Default', | ||
fields: [], | ||
}, | ||
], | ||
|
||
properties: {}, | ||
|
||
required: [], | ||
}; | ||
|
||
export default schema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
div#view .ui.container > .site-location-map-wrapper, | ||
div#view .ui.container > .site-location-map { | ||
margin-bottom: 0; | ||
} | ||
|
||
.site-location-map { | ||
display: flex; | ||
justify-content: center; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.site-location-map.visible.transition { | ||
display: flex !important; | ||
} | ||
|
||
.site-location-map .ol-map { | ||
height: 400px; | ||
min-height: 400px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.