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';
import PropTypes from 'prop-types';
import esriLoader from 'esri-loader';
console.log(esriLoader);
console.log(React);
console.log(PropTypes);
export class CreateMap extends React.Component {
static defaultProps = {
id: '#jsmap',
width: '100%',
height: '100%',
height: '350px',
};
constructor(props) {
......@@ -19,13 +15,44 @@ export class CreateMap extends React.Component {
view: null,
};
this.mapRef = React.createRef();
window._config = {
userInfo: {
site: '',
},
};
}
componentDidMount() {
let modules = ['gis/Map', 'gis/views/MapView', 'dojo/domReady!'];
loadModules(modules).then(
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),
);
}
......@@ -56,10 +83,8 @@ export function loadModules(modules = [], mapSettings = {}) {
let mergeMapSettings = Object.assign(getMapSettings(), mapSettings);
return new Promise(
function (resolve, reject) {
console.log(esriLoader);
esriLoader.loadModules(modules, mergeMapSettings).then(
function (array) {
console.log(array);
resolve(array);
}.bind(this),
);
......@@ -68,9 +93,10 @@ export function loadModules(modules = [], mapSettings = {}) {
}
export function getMapSettings() {
let origin = location.origin;
return {
url: 'gis/4.9/init.js',
css: 'gis/4.9/gis/css/main.css',
url: origin + '/gis/4.9/init.js',
css: origin + '/gis/4.9/gis/css/main.css',
dojoConfig: {
has: {
'gis-featurelayer-webgl': 1,
......@@ -101,67 +127,67 @@ export function getMapSettings() {
baseUrl: './',
packages: [
{
location: 'gis/4.9/dojo',
location: origin + '/' + 'gis/4.9/dojo',
name: 'dojo',
},
{
location: 'gis/4.9/dijit',
location: origin + '/' + 'gis/4.9/dijit',
name: 'dijit',
},
{
location: 'gis/4.9/dojox',
location: origin + '/' + 'gis/4.9/dojox',
name: 'dojox',
},
{
location: 'gis/4.9/dgrid',
location: origin + '/' + 'gis/4.9/dgrid',
main: 'OnDemandGrid',
name: 'dgrid',
},
{
location: 'gis/4.9/dstore',
location: origin + '/' + 'gis/4.9/dstore',
main: 'Store',
name: 'dstore',
},
{
location: 'gis/4.9/gis',
location: origin + '/' + 'gis/4.9/gis',
name: 'gis',
},
{
location: 'gis/4.9/moment',
location: origin + '/' + 'gis/4.9/moment',
main: 'moment',
name: 'moment',
},
{
location: 'gis/4.9/@dojo',
location: origin + '/' + 'gis/4.9/@dojo',
name: '@dojo',
},
{
location: 'gis/4.9/cldrjs',
location: origin + '/' + 'gis/4.9/cldrjs',
main: 'dist/cldr',
name: 'cldrjs',
},
{
location: 'gis/4.9/globalize',
location: origin + '/' + 'gis/4.9/globalize',
main: 'dist/globalize',
name: 'globalize',
},
{
location: 'gis/4.9/maquette',
location: origin + '/' + 'gis/4.9/maquette',
main: 'dist/maquette.umd',
name: 'maquette',
},
{
location: 'gis/4.9/maquette-css-transitions',
location: origin + '/' + 'gis/4.9/maquette-css-transitions',
main: 'dist/maquette-css-transitions.umd',
name: 'maquette-css-transitions',
},
{
location: 'gis/4.9/maquette-jsx',
location: origin + '/' + 'gis/4.9/maquette-jsx',
main: 'dist/maquette-jsx.umd',
name: 'maquette-jsx',
},
{
location: 'gis/4.9/tslib',
location: origin + '/' + 'gis/4.9/tslib',
main: '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