先上一张效果图 看看是不是大家想要的效果~ ❤️
由于该功能微微复杂一点,为了让大家精准了解
我精简了一下地图代码
大家根据自己的需求将center值和paths,用setState做活就可以了
1.第一步要加入项目package.json中或者直接yarn install它都可以
"@react-google-maps/api": "^2.19.3",
2.加入项目中
import React, {
PureComponent } from 'react';
import {
GoogleMap, LoadScript, PolygonF } from '@react-google-maps/api';
export class Geofences extends PureComponent<{
}, {
}> {
render() {
const key = ''; //谷歌申请的key
const paths = [[
{
lat: -34.397, lng: 150.644 },
{
lat: -34.297, lng: 150.744 },
{
lat: -34.197, lng: 150.644 },
],
[
{
lat: -34.397, lng: 150.644