-
{
- helpers.disableKeyboardEvents(true);
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+
+ return (
+
+
+
+ {
+ helpers.disableKeyboardEvents(true);
+ }}
+ onBlur={() => {
+ helpers.disableKeyboardEvents(false);
+ }}
+ />
- );
- }
+
+ );
}
export default MyMapsPopupLabel;
diff --git a/src/sidebar/components/mymaps/images/email-icon.png b/src/sidebar/components/mymaps/images/email-icon.png
new file mode 100644
index 00000000..7725dbd7
Binary files /dev/null and b/src/sidebar/components/mymaps/images/email-icon.png differ
diff --git a/src/sidebar/components/mymaps/images/loading20.gif b/src/sidebar/components/mymaps/images/loading20.gif
new file mode 100644
index 00000000..d3abebcd
Binary files /dev/null and b/src/sidebar/components/mymaps/images/loading20.gif differ
diff --git a/src/sidebar/components/themes/commercialrealestate/CommercialRealEstate.jsx b/src/sidebar/components/themes/commercialrealestate/CommercialRealEstate.jsx
index 4fa8b491..9aaa302c 100644
--- a/src/sidebar/components/themes/commercialrealestate/CommercialRealEstate.jsx
+++ b/src/sidebar/components/themes/commercialrealestate/CommercialRealEstate.jsx
@@ -11,7 +11,7 @@ import { GeoJSON } from "ol/format.js";
import CommercialRealEstatePopupContent from "./CommercialRealEstatePopupContent.jsx";
import CommercialRealEstateLayers from "./CommercialRealEstateLayers";
const propTypes = ["Vacant Land", "Commercial", "Farm", "Industrial", "Institutional"];
-const polygonLayerName = localConfig.polygonLayerName;
+// const polygonLayerName = localConfig.polygonLayerName;
const pointLayerName = localConfig.pointLayerName;
class CommercialRealEstate extends Component {
constructor(props) {
@@ -110,7 +110,7 @@ class CommercialRealEstate extends Component {
//this.mapClickEvent = () =>
propTypes.forEach((propType) => {
window.map.removeLayer(this.state.layers[propType].pointLayer);
- window.map.removeLayer(this.state.layers[propType].polygonLayer);
+ // window.map.removeLayer(this.state.layers[propType].polygonLayer);
});
window.emitter.emit("hideImageSlider");
@@ -133,21 +133,21 @@ class CommercialRealEstate extends Component {
window.map.addLayer(wmsPointLayer);
- const wmsPolygonLayer = helpers.getImageWMSLayer(serverUrl, polygonLayerName, "geoserver", "_proptype = '" + propType + "'", 200, true);
- wmsPolygonLayer.setVisible(true);
- wmsPolygonLayer.setZIndex(200);
- wmsPolygonLayer.setProperties({
- name: propType,
- tocDisplayName: propType,
- disableParcelClick: false,
- queryable: true,
- });
- window.map.addLayer(wmsPolygonLayer);
+ // const wmsPolygonLayer = helpers.getImageWMSLayer(serverUrl, polygonLayerName, "geoserver", "_proptype = '" + propType + "'", 200, true);
+ // wmsPolygonLayer.setVisible(true);
+ // wmsPolygonLayer.setZIndex(200);
+ // wmsPolygonLayer.setProperties({
+ // name: propType,
+ // tocDisplayName: propType,
+ // disableParcelClick: false,
+ // queryable: true,
+ // });
+ // window.map.addLayer(wmsPolygonLayer);
layers[propType] = {
propType: propType,
pointLayer: wmsPointLayer,
- polygonLayer: wmsPolygonLayer,
+ // polygonLayer: wmsPolygonLayer,
visible: true,
};
});
@@ -169,7 +169,7 @@ class CommercialRealEstate extends Component {
let layers = Object.assign(this.state.layers, {});
layers[layerName].visible = evt.target.checked;
layers[layerName].pointLayer.setVisible(evt.target.checked);
- layers[layerName].polygonLayer.setVisible(evt.target.checked);
+ // layers[layerName].polygonLayer.setVisible(evt.target.checked);
this.setState({ layers: layers });
};
@@ -320,7 +320,7 @@ class CommercialRealEstate extends Component {
params.cql_filter = this.sql;
this.state.layers[propType].pointLayer.getSource().updateParams(params);
- this.state.layers[propType].polygonLayer.getSource().updateParams(params);
+ // this.state.layers[propType].polygonLayer.getSource().updateParams(params);
});
this.setNumRecords();
diff --git a/src/sidebar/components/themes/commercialrealestate/CommercialRealEstateLayerToggler.jsx b/src/sidebar/components/themes/commercialrealestate/CommercialRealEstateLayerToggler.jsx
index 031861d2..f8187ba1 100644
--- a/src/sidebar/components/themes/commercialrealestate/CommercialRealEstateLayerToggler.jsx
+++ b/src/sidebar/components/themes/commercialrealestate/CommercialRealEstateLayerToggler.jsx
@@ -3,8 +3,6 @@ import * as helpers from "../../../../helpers/helpers";
import Collapsible from "react-collapsible";
import information from "./images/information.png";
import url from "url";
-import ThemePopupContent from "../themeComponents/ThemePopupContent.jsx";
-import GeoJSON from "ol/format/GeoJSON.js";
import { unByKey } from "ol/Observable.js";
class CommercialRealEstateLayerToggler extends Component {
diff --git a/src/sidebar/components/themes/five11livefeeds/Five11LiveFeeds.jsx b/src/sidebar/components/themes/five11livefeeds/Five11LiveFeeds.jsx
index cf7a7521..102258e6 100644
--- a/src/sidebar/components/themes/five11livefeeds/Five11LiveFeeds.jsx
+++ b/src/sidebar/components/themes/five11livefeeds/Five11LiveFeeds.jsx
@@ -17,21 +17,23 @@ class ThemeComponent extends Component {
this.mapClickEvent = window.map.on("singleclick", (evt) => {
console.log("click");
if (window.isDrawingOrEditing || window.isCoordinateToolOpen || window.isMeasuring) return;
- var results = window.map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
- if (layer === null || !layer.getVisible()) return;
-
- if (layer.get("name") !== undefined && layer.get("name").indexOf("511") !== -1) {
- console.log(layer);
+ var results = window.map.forEachFeatureAtPixel(
+ evt.pixel,
+ function (feature, layer) {
return [feature, layer.get("name"), layer.get("tocDisplayName")];
+ },
+ {
+ layerFilter: function (layer) {
+ return layer.getVisible() && layer.get("name") !== undefined && layer.get("name").indexOf("511") !== -1;
+ },
}
- });
+ );
if (results !== undefined) {
var feature = results[0];
var layerName = results[1];
var displayName = results[2];
const entries = Object.entries(feature.getProperties());
- console.log(entries);
let propsToShow = [];
entries.forEach((prop) => {
const val = prop[0];
@@ -47,7 +49,6 @@ class ThemeComponent extends Component {
});
if (layerName === "511-mto-cameras") {
- console.log(entries);
window.popup.show(evt.coordinate,
, "MTO Camera");
} else {
console.log("in reg");
diff --git a/src/sidebar/components/themes/localrealestate/LocalRealEstate.jsx b/src/sidebar/components/themes/localrealestate/LocalRealEstate.jsx
index d94e2863..c18d6870 100644
--- a/src/sidebar/components/themes/localrealestate/LocalRealEstate.jsx
+++ b/src/sidebar/components/themes/localrealestate/LocalRealEstate.jsx
@@ -40,8 +40,8 @@ class LocalRealEstate extends Component {
this.setState({ visibleLayers: visibleLayers }, () => {
this.renderImageSlider();
let storage = helpers.getItemsFromStorage(this.storageKey);
- if (storage === undefined) storage = [];
- this.setState({ viewedItems: storage });
+ if (storage === undefined || storage === null) storage = [];
+ this.setState({ viewedItems: storage || [] });
});
}
diff --git a/src/sidebar/components/themes/localrealestate/LocalRealEstateLayerToggler.jsx b/src/sidebar/components/themes/localrealestate/LocalRealEstateLayerToggler.jsx
index 8c22ddd8..fbd5d3ae 100644
--- a/src/sidebar/components/themes/localrealestate/LocalRealEstateLayerToggler.jsx
+++ b/src/sidebar/components/themes/localrealestate/LocalRealEstateLayerToggler.jsx
@@ -8,159 +8,159 @@ import { unByKey } from "ol/Observable.js";
import LocalRealEstatePopupContent from "./LocalRealEstatePopupContent.jsx";
class LocalRealEstateLayerToggler extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- visible: props.layerConfig.visible,
- layer: this.initLayer(),
- styleUrl: null,
- recordCount: null,
- };
- }
-
- handleUrlParameter = () => {
- if (this.props.layerConfig.UrlParameter === undefined) return;
-
- let urlParam = null;
- let query = null;
- this.props.layerConfig.UrlParameter.forEach((item) => {
- if (urlParam === null) urlParam = helpers.getURLParameter(item.parameterName);
- if (urlParam !== null) query = item.fieldName + "=" + urlParam;
- });
-
- if (urlParam === null) return;
- helpers.getWFSGeoJSON(
- this.props.layerConfig.serverUrl,
- this.props.layerConfig.layerName,
- (result) => {
- if (result.length === 0) return;
-
- const feature = result[0];
- const extent = feature.getGeometry().getExtent();
- const center = getCenter(extent);
- helpers.zoomToFeature(feature);
- window.popup.show(
- center,
-
,
- this.props.layerConfig.displayName
- );
- },
- null,
- null,
- query
- );
- };
-
- initLayer = () => {
- // GET LAYER
- const layer = helpers.getImageWMSLayer(url.resolve(this.props.layerConfig.serverUrl, "wms"), this.props.layerConfig.layerName, "geoserver", null, 50);
- layer.setVisible(this.props.layerConfig.visible);
- layer.setZIndex(this.props.layerConfig.zIndex);
- layer.setProperties({
- name: this.props.layerConfig.layerName,
- tocDisplayName: this.props.layerConfig.displayName,
- queryable: true,
- disableParcelClick: true,
- });
- window.map.addLayer(layer);
- return layer;
- };
-
- componentDidMount() {
- // GET LEGEND
- const styleUrlTemplate = (serverURL, layerName, styleName) =>
- `${serverURL}/wms?REQUEST=GetLegendGraphic&VERSION=1.1&FORMAT=image/png&WIDTH=20&HEIGHT=20&TRANSPARENT=true&LAYER=${layerName}&STYLE=${styleName === undefined ? "" : styleName}`;
- const styleUrl = styleUrlTemplate(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, this.props.layerConfig.legendStyleName);
- this.setState({ styleUrl: styleUrl });
-
- // GET RECORD COUNT
- helpers.getWFSLayerRecordCount(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, (count) => {
- this.setState({ recordCount: count });
- });
-
- this.mapClickEvent = window.map.on("click", (evt) => {
- // DISABLE POPUPS
- if (window.isDrawingOrEditing || window.isCoordinateToolOpen || window.isMeasuring) return;
-
- if (!this.state.visible) return;
-
- var viewResolution = window.map.getView().getResolution();
- var url = this.state.layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
- INFO_FORMAT: "application/json",
- });
- if (url) {
- helpers.getJSON(url, (result) => {
- const features = result.features;
- if (features.length === 0) {
- return;
- }
-
- const geoJSON = new GeoJSON().readFeatures(result);
- const feature = geoJSON[0];
- window.popup.show(
- evt.coordinate,
-
,
- this.props.layerConfig.displayName
- );
- });
- }
- });
-
- // URL PARAMETERS
- this.handleUrlParameter();
- }
-
- onCheckboxChange = (evt) => {
- this.setState({ visible: evt.target.checked });
- this.state.layer.setVisible(evt.target.checked);
- this.props.onLayerVisiblityChange(this.props.layerConfig.displayName, evt.target.checked);
- };
-
- componentWillUnmount() {
- // CLEAN UP
- window.map.removeLayer(this.state.layer);
- unByKey(this.mapClickEvent);
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
{this.props.children}
-
- );
- }
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ visible: props.layerConfig.visible,
+ layer: this.initLayer(),
+ styleUrl: null,
+ recordCount: null,
+ };
+ }
+
+ handleUrlParameter = () => {
+ if (this.props.layerConfig.UrlParameter === undefined) return;
+
+ let urlParam = null;
+ let query = null;
+ this.props.layerConfig.UrlParameter.forEach((item) => {
+ if (urlParam === null) urlParam = helpers.getURLParameter(item.parameterName);
+ if (urlParam !== null) query = item.fieldName + "=" + urlParam;
+ });
+
+ if (urlParam === null) return;
+ helpers.getWFSGeoJSON(
+ this.props.layerConfig.serverUrl,
+ this.props.layerConfig.layerName,
+ (result) => {
+ if (result.length === 0) return;
+
+ const feature = result[0];
+ const extent = feature.getGeometry().getExtent();
+ const center = getCenter(extent);
+ helpers.zoomToFeature(feature);
+ window.popup.show(
+ center,
+
,
+ this.props.layerConfig.displayName
+ );
+ },
+ null,
+ null,
+ query
+ );
+ };
+
+ initLayer = () => {
+ // GET LAYER
+ const layer = helpers.getImageWMSLayer(url.resolve(this.props.layerConfig.serverUrl, "wms"), this.props.layerConfig.layerName, "geoserver", null, 50);
+ layer.setVisible(this.props.layerConfig.visible);
+ layer.setZIndex(this.props.layerConfig.zIndex);
+ layer.setProperties({
+ name: this.props.layerConfig.layerName,
+ tocDisplayName: this.props.layerConfig.displayName,
+ queryable: true,
+ disableParcelClick: true,
+ });
+ window.map.addLayer(layer);
+ return layer;
+ };
+
+ componentDidMount() {
+ // GET LEGEND
+ const styleUrlTemplate = (serverURL, layerName, styleName) =>
+ `${serverURL}/wms?REQUEST=GetLegendGraphic&VERSION=1.1&FORMAT=image/png&WIDTH=20&HEIGHT=20&TRANSPARENT=true&LAYER=${layerName}&STYLE=${styleName === undefined ? "" : styleName}`;
+ const styleUrl = styleUrlTemplate(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, this.props.layerConfig.legendStyleName);
+ this.setState({ styleUrl: styleUrl });
+
+ // GET RECORD COUNT
+ helpers.getWFSLayerRecordCount(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, (count) => {
+ this.setState({ recordCount: count });
+ });
+
+ this.mapClickEvent = window.map.on("click", (evt) => {
+ // DISABLE POPUPS
+ if (window.isDrawingOrEditing || window.isCoordinateToolOpen || window.isMeasuring) return;
+
+ if (!this.state.visible) return;
+
+ var viewResolution = window.map.getView().getResolution();
+ var url = this.state.layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
+ INFO_FORMAT: "application/json",
+ });
+ if (url) {
+ helpers.getJSON(url, (result) => {
+ const features = result.features;
+ if (features.length === 0) {
+ return;
+ }
+
+ const geoJSON = new GeoJSON().readFeatures(result);
+ const feature = geoJSON[0];
+ window.popup.show(
+ evt.coordinate,
+
,
+ this.props.layerConfig.displayName
+ );
+ });
+ }
+ });
+
+ // URL PARAMETERS
+ this.handleUrlParameter();
+ }
+
+ onCheckboxChange = (evt) => {
+ this.setState({ visible: evt.target.checked });
+ this.state.layer.setVisible(evt.target.checked);
+ this.props.onLayerVisiblityChange(this.props.layerConfig.displayName, evt.target.checked);
+ };
+
+ componentWillUnmount() {
+ // CLEAN UP
+ window.map.removeLayer(this.state.layer);
+ unByKey(this.mapClickEvent);
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
{this.props.children}
+
+ );
+ }
}
export default LocalRealEstateLayerToggler;
diff --git a/src/sidebar/components/themes/localrealestate/LocalRealEstateRecents.jsx b/src/sidebar/components/themes/localrealestate/LocalRealEstateRecents.jsx
index 02ec0462..ec94e890 100644
--- a/src/sidebar/components/themes/localrealestate/LocalRealEstateRecents.jsx
+++ b/src/sidebar/components/themes/localrealestate/LocalRealEstateRecents.jsx
@@ -5,71 +5,71 @@ import InfoRow from "../../../../helpers/InfoRow.jsx";
import { CSSTransition, TransitionGroup } from "react-transition-group";
class LocalRealEstateRecents extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
+ constructor(props) {
+ super(props);
+ this.state = {};
+ }
- render() {
- return (
-
-
- MY RECENTLY VIEWED ITEMS
-
-
-
There are currently no recently viewed items.
-
-
- {this.props.viewedItems.map((geoJson) => {
- const feature = helpers.getFeatureFromGeoJSON(geoJson);
- return (
-
-
-
-
{
- e.target.onerror = null;
- e.target.src = images["noPhoto.png"];
- }}
- alt="not found"
- />
-
-
-
-
-
-
-
-
-
-
-
- );
- })}
-
-
-
- );
- }
+ render() {
+ return (
+
+
+ MY RECENTLY VIEWED ITEMS
+
+
+
There are currently no recently viewed items.
+
+
+ {this.props.viewedItems.map((geoJson) => {
+ const feature = helpers.getFeatureFromGeoJSON(geoJson);
+ return (
+
+
+
+
{
+ e.target.onerror = null;
+ e.target.src = images["noPhoto.png"];
+ }}
+ alt="not found"
+ />
+
+
+
+
+
+
+
+
+
+
+
+ );
+ })}
+
+
+
+ );
+ }
}
export default LocalRealEstateRecents;
@@ -77,7 +77,7 @@ export default LocalRealEstateRecents;
// IMPORT ALL IMAGES
const images = importAllImages(require.context("./images", false, /\.(png|jpe?g|svg|gif)$/));
function importAllImages(r) {
- let images = {};
- r.keys().map((item, index) => (images[item.replace("./", "")] = r(item)));
- return images;
+ let images = {};
+ r.keys().map((item, index) => (images[item.replace("./", "")] = r(item)));
+ return images;
}
diff --git a/src/sidebar/components/themes/themeComponents/ThemeBaseLayers.jsx b/src/sidebar/components/themes/themeComponents/ThemeBaseLayers.jsx
index b4f3815e..a5ba1ef7 100644
--- a/src/sidebar/components/themes/themeComponents/ThemeBaseLayers.jsx
+++ b/src/sidebar/components/themes/themeComponents/ThemeBaseLayers.jsx
@@ -8,169 +8,169 @@ import GeoJSON from "ol/format/GeoJSON.js";
import { unByKey } from "ol/Observable.js";
class ThemeBaseLayers extends Component {
- constructor(props) {
- super(props);
- this.state = {
- layers: [],
- visible: this.props.config.baseLayers.defaultVisibility,
- sliderValue: this.props.config.baseLayers.opacity,
- sliderMin: 0,
- sliderMax: 1,
- legendImageName: this.props.config.baseLayers.legendImageName,
- };
- }
-
- componentDidMount() {
- this.getLayers();
-
- this.mapClickEvent = window.map.on("click", (evt) => {
- console.log(this.state.visible);
- if (window.isDrawingOrEditing || !this.state.visible || window.isCoordinateToolOpen || window.isMeasuring) return;
-
- var viewResolution = window.map.getView().getResolution();
- this.state.layers.forEach((layer) => {
- if (!layer.getProperties().clickable) return;
-
- var url = layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
- INFO_FORMAT: "application/json",
- });
- if (url) {
- helpers.getJSON(url, (result) => {
- const features = result.features;
- if (features.length === 0) {
- return;
- }
-
- const geoJSON = new GeoJSON().readFeatures(result);
- const feature = geoJSON[0];
-
- const entries = Object.entries(feature.getProperties());
- const layerName = layer.getProperties().name;
- const layerConfig = this.getLayerConfigByName(layerName);
- console.log("showing");
- window.popup.show(
- evt.coordinate,
-
,
- layer.getProperties().name
- );
- });
- }
- });
- });
- }
-
- getLayerConfigByName = (name) => {
- let config = {};
- this.props.config.baseLayers.layers.forEach((layerConfig) => {
- //console.log(name);
- //console.log(layerConfig.displayName);
- if (layerConfig.displayName === name) {
- config = layerConfig;
- return;
- }
- });
- return config;
- };
-
- getLayers = () => {
- let layers = [];
- this.props.config.baseLayers.layers.forEach((layerObj) => {
- const layer = helpers.getImageWMSLayer(url.resolve(layerObj.serverUrl, "wms"), layerObj.layerName, "geoserver", null, 50);
- layer.setVisible(this.state.visible);
- layer.setOpacity(this.state.sliderValue);
- layer.setZIndex(this.props.config.baseLayers.zIndex);
- layer.setProperties({
- name: layerObj.displayName,
- tocDisplayName: layerObj.displayName,
- clickable: layerObj.clickable,
- disableParcelClick: layerObj.clickable,
- queryable: true,
- });
- window.map.addLayer(layer);
- layers.push(layer);
- });
-
- this.setState({ layers: layers });
- };
-
- onCheckboxChange = (evt) => {
- this.setState({ visible: evt.target.checked });
-
- this.state.layers.forEach((layer) => {
- layer.setVisible(evt.target.checked);
- });
- };
-
- // SLIDER CHANGE EVENT
- onSliderChange = (value) => {
- this.state.layers.forEach((layer) => {
- layer.setOpacity(value);
- });
-
- this.setState({ sliderValue: value });
- };
-
- componentWillUnmount() {
- // REMOVE THE LAYERS
- this.state.layers.forEach((layer) => {
- window.map.removeLayer(layer);
- });
-
- // REMOVE EVENT
- unByKey(this.mapClickEvent);
- }
-
- render() {
- // MARKS FOR SLIDER
- const marks = {
- 0: {
- style: {
- fontSize: "7pt",
- },
- label:
0
,
- },
- 1: {
- style: {
- fontSize: "7pt",
- },
- label:
100
,
- },
- };
-
- //
-
- return (
-
0 ? "sc-base-layers-container" : "sc-hidden"}>
-
- BASE DATA
-
-
-
-
-
- Transparency
-
-
-
-
-
-
- );
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ layers: [],
+ visible: this.props.config.baseLayers.defaultVisibility,
+ sliderValue: this.props.config.baseLayers.opacity,
+ sliderMin: 0,
+ sliderMax: 1,
+ legendImageName: this.props.config.baseLayers.legendImageName,
+ };
+ }
+
+ componentDidMount() {
+ this.getLayers();
+
+ this.mapClickEvent = window.map.on("click", (evt) => {
+ console.log(this.state.visible);
+ if (window.isDrawingOrEditing || !this.state.visible || window.isCoordinateToolOpen || window.isMeasuring) return;
+
+ var viewResolution = window.map.getView().getResolution();
+ this.state.layers.forEach((layer) => {
+ if (!layer.getProperties().clickable) return;
+
+ var url = layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
+ INFO_FORMAT: "application/json",
+ });
+ if (url) {
+ helpers.getJSON(url, (result) => {
+ const features = result.features;
+ if (features.length === 0) {
+ return;
+ }
+
+ const geoJSON = new GeoJSON().readFeatures(result);
+ const feature = geoJSON[0];
+
+ const entries = Object.entries(feature.getProperties());
+ const layerName = layer.getProperties().name;
+ const layerConfig = this.getLayerConfigByName(layerName);
+ console.log("showing");
+ window.popup.show(
+ evt.coordinate,
+
,
+ layer.getProperties().name
+ );
+ });
+ }
+ });
+ });
+ }
+
+ getLayerConfigByName = (name) => {
+ let config = {};
+ this.props.config.baseLayers.layers.forEach((layerConfig) => {
+ //console.log(name);
+ //console.log(layerConfig.displayName);
+ if (layerConfig.displayName === name) {
+ config = layerConfig;
+ return;
+ }
+ });
+ return config;
+ };
+
+ getLayers = () => {
+ let layers = [];
+ this.props.config.baseLayers.layers.forEach((layerObj) => {
+ const layer = helpers.getImageWMSLayer(url.resolve(layerObj.serverUrl, "wms"), layerObj.layerName, "geoserver", null, 50);
+ layer.setVisible(this.state.visible);
+ layer.setOpacity(this.state.sliderValue);
+ layer.setZIndex(this.props.config.baseLayers.zIndex);
+ layer.setProperties({
+ name: layerObj.displayName,
+ tocDisplayName: layerObj.displayName,
+ clickable: layerObj.clickable,
+ disableParcelClick: layerObj.clickable,
+ queryable: true,
+ });
+ window.map.addLayer(layer);
+ layers.push(layer);
+ });
+
+ this.setState({ layers: layers });
+ };
+
+ onCheckboxChange = (evt) => {
+ this.setState({ visible: evt.target.checked });
+
+ this.state.layers.forEach((layer) => {
+ layer.setVisible(evt.target.checked);
+ });
+ };
+
+ // SLIDER CHANGE EVENT
+ onSliderChange = (value) => {
+ this.state.layers.forEach((layer) => {
+ layer.setOpacity(value);
+ });
+
+ this.setState({ sliderValue: value });
+ };
+
+ componentWillUnmount() {
+ // REMOVE THE LAYERS
+ this.state.layers.forEach((layer) => {
+ window.map.removeLayer(layer);
+ });
+
+ // REMOVE EVENT
+ unByKey(this.mapClickEvent);
+ }
+
+ render() {
+ // MARKS FOR SLIDER
+ const marks = {
+ 0: {
+ style: {
+ fontSize: "7pt",
+ },
+ label:
0
,
+ },
+ 1: {
+ style: {
+ fontSize: "7pt",
+ },
+ label:
100
,
+ },
+ };
+
+ //
+
+ return (
+
0 ? "sc-base-layers-container" : "sc-hidden"}>
+
+ BASE DATA
+
+
+
+
+
+ Transparency
+
+
+
+
+
+
+ );
+ }
}
export default ThemeBaseLayers;
@@ -178,7 +178,7 @@ export default ThemeBaseLayers;
// IMPORT ALL IMAGES
const images = importAllImages(require.context("./images", false, /\.(png|jpe?g|svg|gif)$/));
function importAllImages(r) {
- let images = {};
- r.keys().map((item, index) => (images[item.replace("./", "")] = r(item)));
- return images;
+ let images = {};
+ r.keys().map((item, index) => (images[item.replace("./", "")] = r(item)));
+ return images;
}
diff --git a/src/sidebar/components/themes/themeComponents/ThemeLayerToggler.jsx b/src/sidebar/components/themes/themeComponents/ThemeLayerToggler.jsx
index 0d36f5a1..f1785906 100644
--- a/src/sidebar/components/themes/themeComponents/ThemeLayerToggler.jsx
+++ b/src/sidebar/components/themes/themeComponents/ThemeLayerToggler.jsx
@@ -9,139 +9,139 @@ import { unByKey } from "ol/Observable.js";
// LOOK AT THEME CONFIG FOR EXAMPLE OBJECT BEING PASSED HERE
class ThemeLayerToggler extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- visible: props.layerConfig.visible,
- layer: this.initLayer(),
- styleUrl: null,
- recordCount: null,
- };
- }
-
- handleUrlParameter = () => {
- if (this.props.layerConfig.UrlParameter === undefined) return;
-
- const urlParam = helpers.getURLParameter(this.props.layerConfig.UrlParameter.parameterName);
- if (urlParam === null) return;
-
- const query = this.props.layerConfig.UrlParameter.fieldName + "=" + urlParam;
- helpers.getWFSGeoJSON(
- this.props.layerConfig.serverUrl,
- this.props.layerConfig.layerName,
- (result) => {
- if (result.length === 0) return;
-
- const feature = result[0];
- const extent = feature.getGeometry().getExtent();
- const center = getCenter(extent);
- helpers.zoomToFeature(feature);
- const entries = Object.entries(feature.getProperties());
- window.popup.show(
- center,
-
,
- this.props.layerConfig.displayName
- );
- },
- null,
- null,
- query
- );
- };
-
- initLayer = () => {
- // GET LAYER
- const layer = helpers.getImageWMSLayer(url.resolve(this.props.layerConfig.serverUrl, "wms"), this.props.layerConfig.layerName, "geoserver", null, 50);
- layer.setVisible(this.props.layerConfig.visible);
- layer.setZIndex(this.props.layerConfig.zIndex);
- //layer.setProperties({ name: this.props.layerConfig.layerName, disableParcelClick: true });
- layer.setProperties({
- name: this.props.layerConfig.layerName,
- tocDisplayName: this.props.layerConfig.displayName,
- disableParcelClick: true,
- queryable: true,
- });
-
- window.map.addLayer(layer);
- return layer;
- };
-
- componentDidMount() {
- // GET LEGEND
- const styleUrlTemplate = (serverURL, layerName, styleName) =>
- `${serverURL}/wms?REQUEST=GetLegendGraphic&VERSION=1.1&FORMAT=image/png&WIDTH=20&HEIGHT=20&TRANSPARENT=true&LAYER=${layerName}&STYLE=${styleName === undefined ? "" : styleName}`;
- const styleUrl = styleUrlTemplate(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, this.props.layerConfig.legendStyleName);
- this.setState({ styleUrl: styleUrl });
-
- // GET RECORD COUNT
- helpers.getWFSLayerRecordCount(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, (count) => {
- this.setState({ recordCount: count });
- });
-
- this.mapClickEvent = window.map.on("click", (evt) => {
- if (window.isDrawingOrEditing || !this.state.visible || window.isCoordinateToolOpen || window.isMeasuring) return;
-
- var viewResolution = window.map.getView().getResolution();
- var url = this.state.layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
- INFO_FORMAT: "application/json",
- });
- if (url) {
- helpers.getJSON(url, (result) => {
- const features = result.features;
- if (features.length === 0) {
- return;
- }
-
- const geoJSON = new GeoJSON().readFeatures(result);
- const feature = geoJSON[0];
-
- const entries = Object.entries(feature.getProperties());
- window.popup.show(
- evt.coordinate,
-
,
- this.props.layerConfig.displayName
- );
- });
- }
- });
-
- // URL PARAMETERS
- this.handleUrlParameter();
- }
-
- onCheckboxChange = (evt) => {
- this.setState({ visible: evt.target.checked });
- this.state.layer.setVisible(evt.target.checked);
- this.props.onLayerVisiblityChange(this.state.layer);
- };
-
- componentWillUnmount() {
- // CLEAN UP
- window.map.removeLayer(this.state.layer);
- unByKey(this.mapClickEvent);
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
{this.props.children}
-
- );
- }
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ visible: props.layerConfig.visible,
+ layer: this.initLayer(),
+ styleUrl: null,
+ recordCount: null,
+ };
+ }
+
+ handleUrlParameter = () => {
+ if (this.props.layerConfig.UrlParameter === undefined) return;
+
+ const urlParam = helpers.getURLParameter(this.props.layerConfig.UrlParameter.parameterName);
+ if (urlParam === null) return;
+
+ const query = this.props.layerConfig.UrlParameter.fieldName + "=" + urlParam;
+ helpers.getWFSGeoJSON(
+ this.props.layerConfig.serverUrl,
+ this.props.layerConfig.layerName,
+ (result) => {
+ if (result.length === 0) return;
+
+ const feature = result[0];
+ const extent = feature.getGeometry().getExtent();
+ const center = getCenter(extent);
+ helpers.zoomToFeature(feature);
+ const entries = Object.entries(feature.getProperties());
+ window.popup.show(
+ center,
+
,
+ this.props.layerConfig.displayName
+ );
+ },
+ null,
+ null,
+ query
+ );
+ };
+
+ initLayer = () => {
+ // GET LAYER
+ const layer = helpers.getImageWMSLayer(url.resolve(this.props.layerConfig.serverUrl, "wms"), this.props.layerConfig.layerName, "geoserver", null, 50);
+ layer.setVisible(this.props.layerConfig.visible);
+ layer.setZIndex(this.props.layerConfig.zIndex);
+ //layer.setProperties({ name: this.props.layerConfig.layerName, disableParcelClick: true });
+ layer.setProperties({
+ name: this.props.layerConfig.layerName,
+ tocDisplayName: this.props.layerConfig.displayName,
+ disableParcelClick: true,
+ queryable: true,
+ });
+
+ window.map.addLayer(layer);
+ return layer;
+ };
+
+ componentDidMount() {
+ // GET LEGEND
+ const styleUrlTemplate = (serverURL, layerName, styleName) =>
+ `${serverURL}/wms?REQUEST=GetLegendGraphic&VERSION=1.1&FORMAT=image/png&WIDTH=20&HEIGHT=20&TRANSPARENT=true&LAYER=${layerName}&STYLE=${styleName === undefined ? "" : styleName}`;
+ const styleUrl = styleUrlTemplate(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, this.props.layerConfig.legendStyleName);
+ this.setState({ styleUrl: styleUrl });
+
+ // GET RECORD COUNT
+ helpers.getWFSLayerRecordCount(this.props.layerConfig.serverUrl, this.props.layerConfig.layerName, (count) => {
+ this.setState({ recordCount: count });
+ });
+
+ this.mapClickEvent = window.map.on("click", (evt) => {
+ if (window.isDrawingOrEditing || !this.state.visible || window.isCoordinateToolOpen || window.isMeasuring) return;
+
+ var viewResolution = window.map.getView().getResolution();
+ var url = this.state.layer.getSource().getFeatureInfoUrl(evt.coordinate, viewResolution, "EPSG:3857", {
+ INFO_FORMAT: "application/json",
+ });
+ if (url) {
+ helpers.getJSON(url, (result) => {
+ const features = result.features;
+ if (features.length === 0) {
+ return;
+ }
+
+ const geoJSON = new GeoJSON().readFeatures(result);
+ const feature = geoJSON[0];
+
+ const entries = Object.entries(feature.getProperties());
+ window.popup.show(
+ evt.coordinate,
+
,
+ this.props.layerConfig.displayName
+ );
+ });
+ }
+ });
+
+ // URL PARAMETERS
+ this.handleUrlParameter();
+ }
+
+ onCheckboxChange = (evt) => {
+ this.setState({ visible: evt.target.checked });
+ this.state.layer.setVisible(evt.target.checked);
+ this.props.onLayerVisiblityChange(this.state.layer);
+ };
+
+ componentWillUnmount() {
+ // CLEAN UP
+ window.map.removeLayer(this.state.layer);
+ unByKey(this.mapClickEvent);
+ }
+
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
{this.props.children}
+
+ );
+ }
}
export default ThemeLayerToggler;
diff --git a/src/sidebar/components/themes/themeComponents/ThemePopupContent.css b/src/sidebar/components/themes/themeComponents/ThemePopupContent.css
index 3e2733e2..7b4807c9 100644
--- a/src/sidebar/components/themes/themeComponents/ThemePopupContent.css
+++ b/src/sidebar/components/themes/themeComponents/ThemePopupContent.css
@@ -1,5 +1,6 @@
.sc-theme-popup-content-more-info {
- width: 172px;
+ width: 156px;
+ padding: 5px;
margin-right: 5px;
margin-top: 5px;
}
diff --git a/src/sidebar/components/themes/twooneone/TwoOneOne.jsx b/src/sidebar/components/themes/twooneone/TwoOneOne.jsx
index 177b2e04..da68b789 100644
--- a/src/sidebar/components/themes/twooneone/TwoOneOne.jsx
+++ b/src/sidebar/components/themes/twooneone/TwoOneOne.jsx
@@ -1,10 +1,12 @@
-import React, { Component } from "react";
+import React, { useState, useEffect, useRef } from "react";
import "./TwoOneOne.css";
+import * as themeConfig from "./config.json";
+
import * as helpers from "../../../../helpers/helpers";
import PanelComponent from "../../../PanelComponent";
import Select from "react-select";
import InfoRow from "../../../../helpers/InfoRow.jsx";
-import { AutoSizer, List, CellMeasurerCache } from "react-virtualized";
+import { AutoSizer, List } from "react-virtualized";
import "react-virtualized/styles.css";
import redDot from "./images/red-dot.png";
import { Vector as VectorSource } from "ol/source.js";
@@ -57,70 +59,106 @@ const ageCategoriesFrench = [
},
];
-class TwoOneOne extends Component {
- constructor(props) {
- super(props);
- this.cache = new CellMeasurerCache({
- fixedWidth: true,
- defaultHeight: 144,
- });
-
- this.state = {
- categories: [],
- categorySelectedOption: null,
- subCategories: [],
- subCategorySelectedOption: null,
- results: [],
- ageCategorySelectedOption: ageCategoriesEnglish[0],
- backToTopVisible: false,
- scrollTop: 0,
- searchText: "",
- onlyFeaturesInMap: false,
- isFrench: false,
- };
- }
-
- componentWillMount() {
+const TwoOneOne = (props) => {
+ const vectorSource = useRef(
+ new VectorSource({
+ features: [],
+ })
+ );
+ const [categories, setCategories] = useState([]);
+ const [categorySelectedOption, setCategorySelectedOption] = useState({ value: "All", label: "All" });
+ const [subCategories, setSubCategories] = useState([]);
+ const [subCategorySelectedOption, setSubCategorySelectedOption] = useState({ value: "All", label: "All" });
+ const [results, setResults] = useState([]);
+ const [ageCategorySelectedOption, setAgeCategorySelectedOption] = useState(ageCategoriesEnglish[0]);
+ const [searchText, setSearchText] = useState("");
+ const [onlyFeaturesInMap, setOnlyFeaturesInMap] = useState(false);
+ const [isFrench, setIsFrench] = useState(false);
+ const apiUrl = useRef(null);
+ const mapMoveEvent = useRef(null);
+ const mapClickEvent = useRef(null);
+ const onlyFeaturesInMapRef = useRef(onlyFeaturesInMap);
+ const searchTextRef = useRef(searchText);
+ const ageCategorySelectedOptionRef = useRef(ageCategorySelectedOption);
+ const subCategorySelectedOptionRef = useRef(subCategorySelectedOption);
+ const categorySelectedOptionRef = useRef(categorySelectedOption);
+ const isFrenchRef = useRef(isFrench);
+ const layer = useRef(null);
+
+ useEffect(() => {
helpers.waitForLoad("settings", Date.now(), 30, () => {
- this.apiUrl = window.config.apiUrl;
-
- this.createLayer();
- this.getCategories();
+ apiUrl.current = themeConfig.default.apiUrl;
+ mapClickEvent.current = window.map.on("click", (evt) => {
+ // DISABLE POPUPS
+ if (window.isDrawingOrEditing || window.isCoordinateToolOpen || window.isMeasuring) return;
+
+ const feature = window.map.forEachFeatureAtPixel(
+ evt.pixel,
+ function (feature, layer) {
+ return feature;
+ },
+ {
+ layerFilter: function (layer) {
+ return layer.get("name") !== undefined && layer.get("name") === "sc-211";
+ },
+ }
+ );
+ if (feature !== undefined) window.popup.show(feature.getGeometry().flatCoordinates,
, "Information");
+ });
+ mapMoveEvent.current = window.map.on("moveend", () => {
+ if (onlyFeaturesInMapRef.current) updateResults();
+ });
+ createLayer();
+ getCategories();
});
- }
+ }, []);
- componentWillUnmount() {
- unByKey(this.mapClickEvent);
- unByKey(this.mapMoveEvent);
- window.map.removeLayer(this.layer);
- }
+ useEffect(() => {
+ updateSubCategories();
+ }, [categorySelectedOption, isFrench]);
- getCategories = () => {
+ useEffect(() => {
+ updateResults();
+ }, [ageCategorySelectedOption, isFrench, categorySelectedOption, subCategorySelectedOption, onlyFeaturesInMap, searchText]);
+
+ const getCategories = () => {
let categories = [];
- helpers.getJSON(this.apiUrl + "public/map/theme/211/Categories/" + this.state.isFrench, (result) => {
+ helpers.getJSON(apiUrl.current + "public/map/theme/211/Categories/" + isFrench, (result) => {
categories.push({
value: "All",
- label: this.state.isFrench ? "Tout" : "All",
+ label: isFrench ? "Tout" : "All",
});
result.forEach((category) => {
categories.push({ value: category, label: category });
});
- this.setState({ categories }, () => {
- this.setState({ categorySelectedOption: categories[0] }, () => {
- this.updateSubCategories();
- });
- });
+ setCategories(categories);
+ setCategorySelectedOption(categories[0]);
});
};
+ const updateSubCategories = () => {
+ let subCategories = [];
+ const subCategoriesUrl = apiUrl.current + "public/map/theme/211/SubCategories/" + encodeURIComponent(categorySelectedOption.value) + "/" + isFrench;
+ helpers.getJSON(subCategoriesUrl, (result) => {
+ subCategories.push({
+ value: "All",
+ label: isFrench ? "Tout" : "All",
+ });
+ result.forEach((subCategory) => {
+ subCategories.push({ value: subCategory, label: subCategory });
+ });
- createLayer = () => {
- this.vectorSource = new VectorSource({
+ setSubCategories(subCategories);
+ setSubCategorySelectedOption(subCategories[0]);
+ });
+ };
+ const createLayer = () => {
+ vectorSource.current = new VectorSource({
features: [],
});
- this.layer = new VectorLayer({
- source: this.vectorSource,
+ layer.current = new VectorLayer({
+ source: vectorSource.current,
zIndex: 1000,
name: "sc-211",
style: new Style({
@@ -129,111 +167,88 @@ class TwoOneOne extends Component {
}),
}),
});
- this.layer.set("disableParcelClick", true);
- window.map.addLayer(this.layer);
-
- this.mapClickEvent = window.map.on("click", (evt) => {
- // DISABLE POPUPS
- if (window.isDrawingOrEditing || window.isCoordinateToolOpen || window.isMeasuring) return;
-
- const feature = window.map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
- if (layer === null) return;
-
- if (layer.get("name") !== undefined && layer.get("name") === "sc-211") return feature;
- });
- if (feature !== undefined) window.popup.show(feature.getGeometry().flatCoordinates,
, "Information");
- });
-
- this.mapMoveEvent = window.map.on("moveend", () => {
- if (this.state.onlyFeaturesInMap) this.updateResults();
- });
- };
-
- updateSubCategories = () => {
- let subCategories = [];
- const subCategoriesUrl = this.apiUrl + "public/map/theme/211/SubCategories/" + encodeURIComponent(this.state.categorySelectedOption.value) + "/" + this.state.isFrench;
- helpers.getJSON(subCategoriesUrl, (result) => {
- subCategories.push({
- value: "All",
- label: this.state.isFrench ? "Tout" : "All",
- });
- result.forEach((subCategory) => {
- subCategories.push({ value: subCategory, label: subCategory });
- });
-
- this.setState({ subCategories }, () => {
- this.setState({ subCategorySelectedOption: subCategories[0] }, () => {
- this.updateResults();
- });
- });
- });
+ layer.current.set("disableParcelClick", true);
+ window.map.addLayer(layer.current);
};
- updateResults = () => {
+ const updateResults = () => {
const resultsUrlTemplate = (apiUrl, category, subCategory, age, isFrench) =>
`${apiUrl}public/map/theme/211/Results/${encodeURIComponent(category)}/${encodeURIComponent(subCategory)}/${encodeURIComponent(age)}/${isFrench}`;
const url = resultsUrlTemplate(
- this.apiUrl,
- this.state.categorySelectedOption.value,
- this.state.categorySelectedOption.value === "All" ? "All" : this.state.subCategorySelectedOption.value,
- this.state.ageCategorySelectedOption.value,
- this.state.isFrench
+ apiUrl.current,
+ categorySelectedOptionRef.current.value,
+ categorySelectedOptionRef.current.value === "All" ? "All" : subCategorySelectedOptionRef.current.value,
+ ageCategorySelectedOptionRef.current.value,
+ isFrenchRef.current
);
- helpers.getJSON(url, (results) => {
- this.setState({ results }, () => {
- this.List.Grid._scrollingContainer.scrollTop = 100;
- setTimeout(() => {
- this.List.Grid._scrollingContainer.scrollTop = 0;
- }, 20);
+ helpers.getJSON(url, (apiResults) => {
+ // FILTER RESULTS FROM SEARCH INPUT
+ // eslint-disable-next-line
+ let filteredResults = apiResults.filter((item) => {
+ if (searchTextRef.current === "") return item;
+ else if (item.organization_program_name.toUpperCase().indexOf(searchTextRef.current.toUpperCase()) !== -1) return item;
});
-
- this.vectorSource.clear();
- results.forEach((item) => {
+ vectorSource.current.clear();
+ filteredResults.map((item) => {
const coords = helpers.toWebMercatorFromLatLong([item.longitude.replace(",", "."), Math.abs(item.latitude.replace(",", "."))]);
let feature = new Feature(new Point(coords));
feature.setProperties(item);
- this.vectorSource.addFeature(feature);
+ vectorSource.current.addFeature(feature);
});
+
+ // ONLY IN MAP
+ if (onlyFeaturesInMapRef.current) {
+ const extent = window.map.getView().calculateExtent(window.map.getSize());
+ const features = vectorSource.current.getFeaturesInExtent(extent);
+ filteredResults = apiResults.filter((item) => {
+ const featuresFound = features.filter((itemFeature) => {
+ return item["record_#"] === itemFeature.get("record_#") ? true : false;
+ });
+ return featuresFound.length > 0 ? true : false;
+ });
+ }
+
+ setResults(filteredResults);
});
};
- onClose = () => {
+ const onClose = () => {
// ADD CLEAN UP HERE (e.g. Map Layers, Popups, etc)
+ unByKey(mapClickEvent.current);
+ unByKey(mapMoveEvent.current);
+ window.map.removeLayer(layer.current);
// CALL PARENT WITH CLOSE
- this.props.onClose();
+ props.onClose();
};
- onChangeCategory = (selectedOption) => {
- this.setState({ categorySelectedOption: selectedOption }, () => {
- this.updateSubCategories();
- });
+ const onChangeCategory = (selectedOption) => {
+ setCategorySelectedOption(selectedOption);
+ categorySelectedOptionRef.current = selectedOption;
};
- onChangeSubCategory = (selectedOption) => {
- this.setState({ subCategorySelectedOption: selectedOption }, () => {
- this.updateResults();
- });
+ const onChangeSubCategory = (selectedOption) => {
+ setSubCategorySelectedOption(selectedOption);
+ subCategorySelectedOptionRef.current = selectedOption;
};
- onChangeAgeCategory = (selectedOption) => {
- this.setState({ ageCategorySelectedOption: selectedOption }, () => {
- this.updateResults();
- });
+ const onChangeAgeCategory = (selectedOption) => {
+ setAgeCategorySelectedOption(selectedOption);
+ ageCategorySelectedOptionRef.current = selectedOption;
};
- onChangeSearchTextbox = (evt) => {
- this.setState({ searchText: evt.target.value });
+ const onChangeSearchTextbox = (evt) => {
+ setSearchText(evt.target.value);
+ searchTextRef.current = evt.target.value;
};
- onOnlyFeatureInMap = (evt) => {
- this.setState({ onlyFeaturesInMap: evt.target.checked }, () => {
- this.updateResults();
- });
+ const onOnlyFeatureInMap = (evt) => {
+ setOnlyFeaturesInMap(evt.target.checked);
+ onlyFeaturesInMapRef.current = evt.target.checked;
};
- onZoomClick = (item) => {
+ const onZoomClick = (item) => {
const coords = helpers.toWebMercatorFromLatLong([item.longitude, Math.abs(item.latitude)]);
let feature = new Feature(new Point(coords));
feature.setProperties(item);
@@ -241,34 +256,25 @@ class TwoOneOne extends Component {
window.popup.show(feature.getGeometry().flatCoordinates,
, "Information");
};
- onLangChange = (isFrench) => {
- this.setState(
- {
- isFrench,
- ageCategorySelectedOption: isFrench ? ageCategoriesFrench[0] : ageCategoriesEnglish[0],
- },
- () => {
- this.getCategories();
- }
- );
+ const onLangChange = (isFrench) => {
+ setIsFrench(isFrench);
+ setAgeCategorySelectedOption(isFrench ? ageCategoriesFrench[0] : ageCategoriesEnglish[0]);
+ isFrenchRef.current = isFrench;
+ ageCategorySelectedOptionRef.current = isFrench ? ageCategoriesFrench[0] : ageCategoriesEnglish[0];
helpers.addAppStat("211 Lang Switch", "Click");
};
- registerListRef = (listInstance) => {
- this.List = listInstance;
- };
-
- _rowRenderer = ({ index, parent, key, style }) => {
- const row = this.results[index];
+ const _rowRenderer = ({ index, parent, key, style }) => {
+ const row = results[index];
return (
-
+
);
};
- _getRowHeight = (evt) => {
- const row = this.results[evt.index];
+ const _getRowHeight = (evt) => {
+ const row = results[evt.index];
if (row.organization_program_name.length <= 35) {
return 72;
@@ -288,119 +294,79 @@ class TwoOneOne extends Component {
return 120;
}
};
+ const dropdownStyles = {
+ control: (provided) => ({
+ ...provided,
+ minHeight: "30px",
+ marginBottom: "5px",
+ }),
+ indicatorsContainer: (provided) => ({
+ ...provided,
+ height: "30px",
+ }),
+ clearIndicator: (provided) => ({
+ ...provided,
+ padding: "5px",
+ }),
+ dropdownIndicator: (provided) => ({
+ ...provided,
+ padding: "5px",
+ }),
+ };
+ useEffect(() => {
+ if (categorySelectedOption === null) return
;
+ });
- render() {
- const dropdownStyles = {
- control: (provided) => ({
- ...provided,
- minHeight: "30px",
- marginBottom: "5px",
- }),
- indicatorsContainer: (provided) => ({
- ...provided,
- height: "30px",
- }),
- clearIndicator: (provided) => ({
- ...provided,
- padding: "5px",
- }),
- dropdownIndicator: (provided) => ({
- ...provided,
- padding: "5px",
- }),
- };
- if (this.state.categorySelectedOption === null) return
;
-
- // FILTER RESULTS FROM SEARCH INPUT
- // eslint-disable-next-line
- this.results = this.state.results.filter((item) => {
- if (this.state.searchText === "") return item;
-
- if (item.organization_program_name.toUpperCase().indexOf(this.state.searchText.toUpperCase()) !== -1) return item;
- });
-
- // ONLY IN MAP
- if (this.state.onlyFeaturesInMap) {
- const extent = window.map.getView().calculateExtent(window.map.getSize());
- const features = this.vectorSource.getFeaturesInExtent(extent);
-
- this.results = this.results.filter((item) => {
- const featuresFound = features.filter((itemFeature) => {
- return item["record_#"] === itemFeature.get("record_#") ? true : false;
- });
- return featuresFound.length > 0 ? true : false;
- });
- }
-
- return (
-
-
-