问题
i'm tring to reproduce the example show in: https://developers.google.com/maps/documentation/javascript/examples/maptype-image
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>
i try to do something like that
回答1:
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 ]
]}
to link it the map. defaultExtraMapTypes replace the map.set in the google api.
来源:https://stackoverflow.com/questions/53139750/can-react-google-maps-use-image-map-types