react-google-maps可以使用图片地图类型吗? [英] Can react-google-maps use Image Map Types?

查看:137
本文介绍了react-google-maps可以使用图片地图类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重现以下示例中的示例: https://developers.google.com/maps/documentation/javascript/examples/maptype-image

i'm tring to reproduce the example show in: https://developers.google.com/maps/documentation/javascript/examples/maptype-image

带有react-google-maps.它似乎没有相同的类google.maps.ImageMapType.您是否知道是否有可以帮助我的课程,或者是否有人已经为我提供了示例?

with react-google-maps. it doesn't seem to have the same class google.maps.ImageMapType. Did u know if there's a class that can help me or if someone already did this, link me the example?

  <GoogleMap
className="maps"
defaultZoom={17}
defaultCenter={{ lat: 46.215951, lng: 12.306994 }}
defaultMapTypeId="moon"
defaultExtraMapTypes={[{id:"moon", mapType:{
      getTileUrl: function(coord, zoom) {
          return "mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw/1/1/0.jpg";
      },
      maxZoom: 9,
      minZoom: 0,
      radius: 1738000,
      name: 'Moon'
    }}]}
defaultOptions={{
 // these following 7 options turn certain controls off see link below
  streetViewControl: false,
  scaleControl: false,
  mapTypeControl: false,
  panControl: false,
  zoomControl: false,
  rotateControl: false,
  fullscreenControl: false
}}

disableDefaultUI>

我尝试做类似的事情

推荐答案

我找到了窍门.我像示例show一样创建const ImageMapType并将其导出.

I find the trick. I create the const ImageMapType like the example show and exported it.

在我的地图组件中,我使用以下属性:

in my map component i use these properties:

defaultOptions={{
              maxZoom: 18,
              mapTypeControlOptions: {
                mapTypeIds: ['moon','satellite']
              }
          }}
          mapTypeId={google ? 'moon' : 'satellite'}
          defaultExtraMapTypes={[
              ['moon', mapStyles ]
          ]}

以将其链接到地图.defaultExtraMapTypes替换Google API中的map.set.

to link it the map. defaultExtraMapTypes replace the map.set in the google api.

这篇关于react-google-maps可以使用图片地图类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆