如何设置缩放控制选项?

时间:2019-05-20 11:30:22

标签: javascript reactjs react-google-maps

使用printCalendar(),我以下用于更改缩放位置的选项不起作用

react-google-maps

>

1 个答案:

答案 0 :(得分:1)

来自zoomControlOptions类型定义(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/googlemaps/index.d.ts)的

react-google-maps道具形状:

  /** Options for the rendering of the zoom control. */
  export interface ZoomControlOptions {
    /**
     * Position id. Used to specify the position of the control on the map.
     * The default position is TOP_LEFT.
     */
    position?: ControlPosition;
    style?: ZoomControlStyle;
  }

export enum ControlPosition {
  BOTTOM_CENTER,
  BOTTOM_LEFT,
  BOTTOM_RIGHT,
  LEFT_BOTTOM,
  LEFT_CENTER,
  LEFT_TOP,
  RIGHT_BOTTOM,
  RIGHT_CENTER,
  RIGHT_TOP,
  TOP_CENTER,
  TOP_LEFT,
  TOP_RIGHT
}

这应该有效:

<GoogleMap
  defaultZoom={5}
  defaultCenter={{ lat: 22.845625996700075, lng: 78.9629 }}
  options={{
    gestureHandling:'greedy',
    zoomControlOptions: { position: 9 },
    streetViewControl:false,
    fullscreenControl:false,
  }}
>

google.maps.ControlPosition.TOP_CENTER的值为9