Commit 1ff75e0b authored by 邹绪超's avatar 邹绪超

fix: 修复资源路径

parent c8ca64c9
Pipeline #20374 passed with stages
in 2 minutes 35 seconds
...@@ -2,15 +2,11 @@ import React from 'react'; ...@@ -2,15 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import esriLoader from 'esri-loader'; import esriLoader from 'esri-loader';
console.log(esriLoader);
console.log(React);
console.log(PropTypes);
export class CreateMap extends React.Component { export class CreateMap extends React.Component {
static defaultProps = { static defaultProps = {
id: '#jsmap', id: '#jsmap',
width: '100%', width: '100%',
height: '100%', height: '350px',
}; };
constructor(props) { constructor(props) {
...@@ -19,13 +15,44 @@ export class CreateMap extends React.Component { ...@@ -19,13 +15,44 @@ export class CreateMap extends React.Component {
view: null, view: null,
}; };
this.mapRef = React.createRef(); this.mapRef = React.createRef();
window._config = {
userInfo: {
site: '',
},
};
} }
componentDidMount() { componentDidMount() {
let modules = ['gis/Map', 'gis/views/MapView', 'dojo/domReady!']; let modules = ['gis/Map', 'gis/views/MapView', 'dojo/domReady!'];
loadModules(modules).then( loadModules(modules).then(
function (results) { function (results) {
console.log(results); let Map = results[0];
let MapView = results[1];
const map = new Map({
basemap: 'satellite',
});
// Create a MapView instance (for 2D viewing) and reference the map instance
const view = new MapView({
center: [120.2, 32.1],
map: map,
container: this.mapRef.current,
zoom: 5,
});
view.when(
function () {
console.log('resolved');
// This function will execute once the promise is resolved
},
function (error) {
console.log(error);
// This function will execute if the promise is rejected due to an error
},
);
window.viewLocal = view;
console.log(window.viewLocal);
}.bind(this), }.bind(this),
); );
} }
...@@ -56,10 +83,8 @@ export function loadModules(modules = [], mapSettings = {}) { ...@@ -56,10 +83,8 @@ export function loadModules(modules = [], mapSettings = {}) {
let mergeMapSettings = Object.assign(getMapSettings(), mapSettings); let mergeMapSettings = Object.assign(getMapSettings(), mapSettings);
return new Promise( return new Promise(
function (resolve, reject) { function (resolve, reject) {
console.log(esriLoader);
esriLoader.loadModules(modules, mergeMapSettings).then( esriLoader.loadModules(modules, mergeMapSettings).then(
function (array) { function (array) {
console.log(array);
resolve(array); resolve(array);
}.bind(this), }.bind(this),
); );
...@@ -68,9 +93,10 @@ export function loadModules(modules = [], mapSettings = {}) { ...@@ -68,9 +93,10 @@ export function loadModules(modules = [], mapSettings = {}) {
} }
export function getMapSettings() { export function getMapSettings() {
let origin = location.origin;
return { return {
url: 'gis/4.9/init.js', url: origin + '/gis/4.9/init.js',
css: 'gis/4.9/gis/css/main.css', css: origin + '/gis/4.9/gis/css/main.css',
dojoConfig: { dojoConfig: {
has: { has: {
'gis-featurelayer-webgl': 1, 'gis-featurelayer-webgl': 1,
...@@ -101,67 +127,67 @@ export function getMapSettings() { ...@@ -101,67 +127,67 @@ export function getMapSettings() {
baseUrl: './', baseUrl: './',
packages: [ packages: [
{ {
location: 'gis/4.9/dojo', location: origin + '/' + 'gis/4.9/dojo',
name: 'dojo', name: 'dojo',
}, },
{ {
location: 'gis/4.9/dijit', location: origin + '/' + 'gis/4.9/dijit',
name: 'dijit', name: 'dijit',
}, },
{ {
location: 'gis/4.9/dojox', location: origin + '/' + 'gis/4.9/dojox',
name: 'dojox', name: 'dojox',
}, },
{ {
location: 'gis/4.9/dgrid', location: origin + '/' + 'gis/4.9/dgrid',
main: 'OnDemandGrid', main: 'OnDemandGrid',
name: 'dgrid', name: 'dgrid',
}, },
{ {
location: 'gis/4.9/dstore', location: origin + '/' + 'gis/4.9/dstore',
main: 'Store', main: 'Store',
name: 'dstore', name: 'dstore',
}, },
{ {
location: 'gis/4.9/gis', location: origin + '/' + 'gis/4.9/gis',
name: 'gis', name: 'gis',
}, },
{ {
location: 'gis/4.9/moment', location: origin + '/' + 'gis/4.9/moment',
main: 'moment', main: 'moment',
name: 'moment', name: 'moment',
}, },
{ {
location: 'gis/4.9/@dojo', location: origin + '/' + 'gis/4.9/@dojo',
name: '@dojo', name: '@dojo',
}, },
{ {
location: 'gis/4.9/cldrjs', location: origin + '/' + 'gis/4.9/cldrjs',
main: 'dist/cldr', main: 'dist/cldr',
name: 'cldrjs', name: 'cldrjs',
}, },
{ {
location: 'gis/4.9/globalize', location: origin + '/' + 'gis/4.9/globalize',
main: 'dist/globalize', main: 'dist/globalize',
name: 'globalize', name: 'globalize',
}, },
{ {
location: 'gis/4.9/maquette', location: origin + '/' + 'gis/4.9/maquette',
main: 'dist/maquette.umd', main: 'dist/maquette.umd',
name: 'maquette', name: 'maquette',
}, },
{ {
location: 'gis/4.9/maquette-css-transitions', location: origin + '/' + 'gis/4.9/maquette-css-transitions',
main: 'dist/maquette-css-transitions.umd', main: 'dist/maquette-css-transitions.umd',
name: 'maquette-css-transitions', name: 'maquette-css-transitions',
}, },
{ {
location: 'gis/4.9/maquette-jsx', location: origin + '/' + 'gis/4.9/maquette-jsx',
main: 'dist/maquette-jsx.umd', main: 'dist/maquette-jsx.umd',
name: 'maquette-jsx', name: 'maquette-jsx',
}, },
{ {
location: 'gis/4.9/tslib', location: origin + '/' + 'gis/4.9/tslib',
main: 'tslib', main: 'tslib',
name: 'tslib', name: 'tslib',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment