Skip to content

Commit

Permalink
测试版本
Browse files Browse the repository at this point in the history
  • Loading branch information
徐海涛 committed Oct 12, 2020
1 parent b1da296 commit 1a42955
Show file tree
Hide file tree
Showing 21 changed files with 20,159 additions and 380 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"react-app",
{
"absoluteRuntime": false
}
]
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 徐海涛

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 0 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

### Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

### Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

### Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

### Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

### `yarn build` fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
82 changes: 82 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import React, { useEffect, useRef } from 'react';
import * as AMapLoader from '@amap/amap-jsapi-loader'; // export interface BF_AMapProps {
// AMapUI: any;
// loca: boolean;
// key: string;
// id: string;
// options: any;
// setMap: Function;
// plugins: string[];
// }

var Index = function Index(props) {
// 参数,plugins:[], id 需要在全局配置
var AMapUI = props.AMapUI,
loca = props.loca,
plugins = props.plugins,
setMap = props.setMap,
options = props.options,
id = props.id,
map_key = props.map_key;
console.log(map_key);
var map = useRef();

var initMap = function initMap() {
var option = {
key: map_key,
version: '2.0',
plugins: (plugins === null || plugins === void 0 ? void 0 : plugins.map(function (im) {
return "AMap.".concat(im);
})) || [] // 需要使用的的插件列表,如比例尺'AMap.Scale'等

};

if (AMapUI) {
// @ts-ignore
option = _objectSpread(_objectSpread({}, option), {}, {
AMapUI: AMapUI
});
}

if (loca) {
// @ts-ignore
option = _objectSpread(_objectSpread({}, option), {}, {
Loca: {
version: '1.3.2'
}
});
}

AMapLoader.load(_objectSpread({}, option)).then(function (AMap) {
var _map = new AMap.Map(id, _objectSpread({}, options));

setMap(_map, AMap);
});
};

useEffect(function () {
if (map.current) {
// @ts-ignore
map.current.style.width = '100%'; // @ts-ignore

map.current.style.height = '100%';
initMap();
}
}, [map]);
if (!setMap || typeof setMap !== 'function') return null;
if (!id) console.error('没有传入唯一ID!,There is no id!');
if (!map_key) console.error('没有传入key!,There is no map key!');
return /*#__PURE__*/React.createElement("div", {
ref: map,
id: id
});
};

export default Index; // AMapUI: { // 是否加载 AMapUI,缺省不加载
// version: '1.1', // AMapUI 缺省 1.1
// plugins: [], // 需要加载的 AMapUI ui插件
// },
// Loca: { // 是否加载 Loca, 缺省不加载
// version: '1.3.2' // Loca 版本,缺省 1.3.2
// },
Loading

0 comments on commit 1a42955

Please sign in to comment.