Commit c8ca64c9 authored by 邹绪超's avatar 邹绪超

feat: init map

parent ae47c945
Pipeline #20332 passed with stages
in 2 minutes 34 seconds
...@@ -126,6 +126,7 @@ ...@@ -126,6 +126,7 @@
} }
], ],
"dependencies": { "dependencies": {
"cross-spawn": "^7.0.3" "cross-spawn": "^7.0.3",
"esri-loader": "^2.16.0"
} }
} }
# @winsdom-components/pro-map
{
"name": "@wisdom-components/pro-map",
"version": "1.0.0",
"description": "map arcgis",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://g.civnet.cn:8443/test/winsdom-components"
},
"keywords": [
"map",
"arcgis",
"component"
],
"author": "zouxuchao",
"license": "ISC",
"dependencies": {
"esri-loader": "^2.16.0"
}
}
import { CreateMap } from '../index';
export default () => {
return <CreateMap />;
};
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%',
};
constructor(props) {
super(props);
this.state = {
view: null,
};
this.mapRef = React.createRef();
}
componentDidMount() {
let modules = ['gis/Map', 'gis/views/MapView', 'dojo/domReady!'];
loadModules(modules).then(
function (results) {
console.log(results);
}.bind(this),
);
}
render() {
return (
<div id={this.props.id} ref={this.mapRef} style={this.getStyle()}>
地图容器
</div>
);
}
getStyle() {
return {
width: this.props.width,
height: this.props.height,
};
}
}
CreateMap.propTypes = {
id: PropTypes.string,
width: PropTypes.string,
height: PropTypes.string,
};
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),
);
}.bind(this),
);
}
export function getMapSettings() {
return {
url: 'gis/4.9/init.js',
css: 'gis/4.9/gis/css/main.css',
dojoConfig: {
has: {
'gis-featurelayer-webgl': 1,
},
aliases: [
[
/^webgl-engine/,
function () {
return 'gis/views/3d/webgl-engine';
},
],
[
/^engine/,
function () {
return 'gis/views/3d/webgl-engine';
},
],
[
/^gis-hydra/,
function () {
return 'gis';
},
],
['text', 'dojo/text'],
],
async: 1,
async: 1,
baseUrl: './',
packages: [
{
location: 'gis/4.9/dojo',
name: 'dojo',
},
{
location: 'gis/4.9/dijit',
name: 'dijit',
},
{
location: 'gis/4.9/dojox',
name: 'dojox',
},
{
location: 'gis/4.9/dgrid',
main: 'OnDemandGrid',
name: 'dgrid',
},
{
location: 'gis/4.9/dstore',
main: 'Store',
name: 'dstore',
},
{
location: 'gis/4.9/gis',
name: 'gis',
},
{
location: 'gis/4.9/moment',
main: 'moment',
name: 'moment',
},
{
location: 'gis/4.9/@dojo',
name: '@dojo',
},
{
location: 'gis/4.9/cldrjs',
main: 'dist/cldr',
name: 'cldrjs',
},
{
location: 'gis/4.9/globalize',
main: 'dist/globalize',
name: 'globalize',
},
{
location: 'gis/4.9/maquette',
main: 'dist/maquette.umd',
name: 'maquette',
},
{
location: 'gis/4.9/maquette-css-transitions',
main: 'dist/maquette-css-transitions.umd',
name: 'maquette-css-transitions',
},
{
location: 'gis/4.9/maquette-jsx',
main: 'dist/maquette-jsx.umd',
name: 'maquette-jsx',
},
{
location: 'gis/4.9/tslib',
main: 'tslib',
name: 'tslib',
},
],
hasCache: {
'config-deferredInstrumentation': 0,
'config-selectorEngine': 'acme',
'config-tlmSiblingOfDojo': 1,
'dojo-built': 1,
'dojo-has-api': 1,
'dojo-loader': 1,
'dojo-undef-api': 0,
dom: 1,
'host-browser': 1,
'gis-built': 1,
'gis-featurelayer-webgl': 0,
'gis-promise-compatibility': !1,
'gis-promise-compatibility-deprecation-warnings': !1,
},
map: {
globalize: {
cldr: 'cldrjs/dist/cldr',
'cldr/event': 'cldrjs/dist/cldr/event',
'cldr/supplemental': 'cldrjs/dist/cldr/supplemental',
'cldr/unresolved': 'cldrjs/dist/cldr/unresolved',
},
},
},
};
}
---
title: Map - 地图组件列表
nav:
title: 组件
path: /components
group:
path: /
---
# MapCoponent 地图组件
展示地图组件,原理使用`esri-loader`组件动态加载本地 arcgis 资源
# 合适使用
- 页面加载初始化地图容器,同时可也以自由搭配地图上面的 UI 控件
## 创建地图
初始化一个地图容器
<code src = "./demos/createMap.jsx">
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