uiwjs / react-amap

基于 React 封装的高德地图组件,帮助你轻松的接入地图到 React 项目中。
https://uiwjs.github.io/react-amap
MIT License
428 stars 70 forks source link

添加行政区域图层不显示 #328

Closed voiddiddvue closed 1 year ago

voiddiddvue commented 1 year ago

官方demo:https://lbs.amap.com/demo/javascript-api/example/district/district-labels 我的代码:

import {
  Map,
  APILoader,
} from '@uiw/react-amap';
import React from 'react';
// import './styles.css';

function Demo() {
  const countryLayer = new AMap.DistrictLayer.Country({
    zIndex: 10,
    SOC: 'CHN',
    depth: 1,
    styles: {
      'nation-stroke': '#0088ff',
      'coastline-stroke': '#0088ff',
      'province-stroke': '#888888',
    }
  });

  return (
    <div style={{ width: '100%', height: '1000px' }}>
      <Map layers={[countryLayer]}>
      </Map>
    </div>
  );
}

export default function App() {
  return (
    <APILoader akey="a7a90e05a37d3f6bf76d4a9032fc9129" version="2.0.5">
      <Demo />
    </APILoader>
  );
}

而如果改成layers={[new AMap.TileLayer.Satellite()]},则没有问题可以正常显示,请问要如何解决呢

voiddiddvue commented 1 year ago

我的锅,有显示