Jim Liu's Blog
liuji-jim / amap-react Goto Github PK
View Code? Open in Web Editor NEWUsing AMap with React in an easy way.
Home Page: https://jimnox.gitee.io/amap-react/
Using AMap with React in an easy way.
Home Page: https://jimnox.gitee.io/amap-react/
此项目是否是 AMap 官方提供?
该项目开源协议?
该 NPM 包没有指定 License 信息,请谨慎使用
😊
地图事件监听器未在state更新后更新。
具体问题请看
https://codesandbox.io/s/amap-hello-forked-i8hyi?file=/src/App.js
以下,button可以正常获得更新后state,marker点击事件获得的state为初始值不变。
import React, { useState } from "react";
import "./styles.css";
import { Amap, Marker } from "@amap/amap-react";
export default function App() {
const [face, setFace] = useState("smile");
const showFace = (from) => {
console.log(`${from}: ${face}`);
};
const changeFace = () => {
showFace("marker");
setFace((face) => (face === "smile" ? "angry" : "smile"));
};
return (
<div className="App">
<div className="map-container">
<Amap zoom={15} center={[116.473179, 39.993169]}>
<Marker
position={[116.473179, 39.993169]}
label={{
content: face,
direction: "bottom"
}}
onClick={changeFace}
/>
<button
style={{ position: "fixed", zIndex: 1000, top: 200 }}
onClick={() => showFace("button")}
>
show face
</button>
</Amap>
</div>
</div>
);
}
新申请的js api key必需配合jscode,能在 config 中支持下 securityJsCode 属性吗?
相关文档如下
https://lbs.amap.com/api/javascript-api/guide/abc/prepare
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.