esri / esri-react-boot Goto Github PK
View Code? Open in Web Editor NEWEsri ArcGIS JS API + React utilizing Redux and Saga
License: Apache License 2.0
Esri ArcGIS JS API + React utilizing Redux and Saga
License: Apache License 2.0
Following basic examples from:
https://www.youtube.com/watch?v=GTXL8YfGS9M
esri-react-boot/src/components/esri/map/Map.js
Line 48 change to:
this.props.config.mapConfig,
(the Map.js example did not work without this change)
Line 84 change to:
this.props.mapLoaded();
esri-react-boot/src/components/esri/map/SceneViewExample.js
Line 48 change to:
this.props.config.mapConfig,
Line 84 change to:
this.props.mapLoaded();
Details here: https://docs.google.com/document/d/17tYzUF45GF-EiWqy5DZ2mDTvjnBUiRGIRbko8-iPrLY/edit?usp=sharing
I found this comment inside the project but still i didn't figure out how can i prevent map from reload
Conceptually, this component creates a "portal" in React by
closing its render method off from updates (by simply rendering a div and
never accepting re-renders) then reconnecting itself to the React lifecycle
by listening for any new props (using componentWillReceiveProps)
I want to send location as props to map then map zoom to this location
my issue that the map component keep re-rendering every time the location change
I'm working on a web app that uses a single sign on event in order to allow access to multiple ArcGIS portal items. The general workflow I'm going for is this:
I'm running into problems with the third step. For some reason, when I include step 3 and try to use the initial login to the app, I get the following error:
SyntaxError: JSON Parse error: Unexpected identifier "<CLIENT ID>"
(Where CLIENT ID is the clientID specified in the config.json file)
I'm using the boilerplate code, except I've adapted it slightly to utilize the Javascript 4.18 modules to be more Reactive. I've included my code for Map.js below.
Any guidance on the best workflow to utilize the initial portal sign in to access portal items without a second login?
Map.js:
import React, { useRef, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { useSelector } from 'react-redux';
import WebMap from '@arcgis/core/WebMap';
import MapView from '@arcgis/core/views/MapView';
import IdentityManager from '@arcgis/core/identity/IdentityManager';
import MapContext from 'context/MapContext';
const MapContainer = styled.div(({ style, theme }) => ({
width: '100%',
height: '100%',
color: theme.lightGrey1,
...style
}));
const Map = ({ children, mapConfig, clientId }) => {
const mapDiv = useRef(null);
const auth = useSelector(state => state.auth);
const [viewObj, setView] = useState(null);
const [mapObj, setMap] = useState(null);
useEffect(() => {
if (auth.token) {
const portalItem = {
id: <PORTAL ID>,
portal: {
portalUrl: <PORTAL URL>,
authMode: 'immediate'
}
};
IdentityManager.registerToken(auth.token);
const map = new WebMap({ ...mapConfig, portalItem });
if (mapDiv.current) {
const view = new MapView({
map,
container: mapDiv.current,
ui: {
components: ['zoom']
}
});
setView(view);
setMap(map);
}
}
}, [auth]);
return (
<MapContext.Provider value={{ viewObj, mapObj }}>
<MapContainer ref={mapDiv}>{children}</MapContainer>
</MapContext.Provider>
);
};
Map.defaultProps = {
children: null,
mapConfig: {},
clientId: ''
};
Map.propTypes = {
children: PropTypes.any,
mapConfig: PropTypes.object,
clientId: PropTypes.string
};
export default Map;
Alternatively, I've been able to get the following workflow to work, but it's not ideal:
The problem with this approach is that you don't have a global login accessible in Redux
I'm thinking that React Hooks will eliminate the need for Redux-Saga to manage side effects.
Thinking about separating out tools into templates like one will include Redux and another will not and use Context instead.
https://github.com/facebook/create-react-app/tree/master/packages/cra-template
I want to see if using arcgis-webpack-plugin makes for a better development experience.
Just had an issue trying to get routes to render properly using <Link>
components. The route would render on a full page refresh, but not when using the <Link to="/myroute" />
component in a Header. After some research that really didn't get me anywhere, I just tried upgrading to "react-router-dom": "5.0.0"
and the Link components started working. Wish I could be more helpful about what the actual problem was, but hopefully this can be of use to anyone else experiencing the same thing.
Hi thanks for such a great work. when ı start the project map loaded but in state doesnt change always false ?
state of map reducer not changed MAP_LOADED action is not triggered . Am I only one having that issue how can I change the state of map loaded to true
I'm trying to implement the 4.14 api to the application. I already changeds the jsapiURL in config, but upon checking the console, 4.13 is what getting loaded. Any solution for this? Thank you.
I am following the Tutorials on ArcGIS Developer,and I am having an issue accessing other basemaps
. In all tutorials they use the API Key, but I assume this would still work here? I even logged in and the map does not show.
"mapConfig": {
"basemap": "arcgis-topographic",
"center": [-118.805, 34.027],
"zoom": 13
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.