React Google Maps API 无法更改标题

问题描述 投票:0回答:1

我正在使用包

react-google-maps/api
并且想要更改地图的标题。关于如何做到这一点有什么建议吗?

我尝试在

<GoogleMap/>
组件中添加标题,并且还尝试在组件的
options
部分中传递值,但它仍然不起作用。

<GoogleMap
  mapContainerStyle={containerStyle}
  center={center}
  gestureHandling="greedy"
  onLoad={onLoad}
  onUnmount={onUnmount}
  options={{
    scrollwheel: true,
    disableDefaultUI: true,
    auto: true,
    noClear: true,
    backgroundColor: 'white',
    enableHighAccuracy: true,
    isFractionalZoomEnabled: true,
    scaleControlOptions: true,
    zoomControl: false,
    streetViewControl: false,
    mapTypeControl: false,
    fullscreenControl: false,
    zoom: 15,
    gestureHandling: 'greedy',        
  }}          
>
reactjs google-maps-api-3 react-google-maps-api
1个回答
1
投票

航向和倾斜仅支持矢量地图。为了使用矢量图,有两个步骤:

  1. 在您的地图管理空间中创建一个使用矢量地图的mapID。 (记得将MapType设置为
    Javascript
    ,选择
    Vector
    作为渲染类型,并勾选
    rotation
  2. options
    属性中设置标题,根据 PR,mapID 也需要位于
    options
    属性中
<GoogleMap
    mapContainerStyle={containerStyle}
    center={center}
    zoom={10}
    onLoad={onLoad}
    onUnmount={onUnmount}
    options = {{
        mapId: 'your-map-id',
        heading: 180
    }}
>
© www.soinside.com 2019 - 2024. All rights reserved.