gpt4 book ai didi

javascript - google-map-react 自定义皮肤

转载 作者:行者123 更新时间:2023-11-30 16:19:15 26 4
gpt4 key购买 nike

我正在使用 React 和 google-map-react 组件。我正在尝试为我的谷歌地图添加皮肤。知道我在哪里做这个吗?我正在尝试使用 snazzymap 皮肤,它们提供了一系列样式。

https://snazzymaps.com/style/25/blue-water

时髦的 map 提供了

import React from 'react';
import ReactDom from 'react-dom';
//import shouldPureComponentUpdate from 'react-pure-render/function';

import GoogleMap from 'google-map-react';
var divStyle = {
paddingTop: 20,
paddingLeft: 20,
paddingRight: 20,
width:1024,
height:768
};
const K_WIDTH = 40;
const K_HEIGHT = 40;

const greatPlaceStyle = {
// initially any map object has left top corner at lat lng coordinates
// it's on you to set object origin to 0,0 coordinates
position: 'absolute',
width: K_WIDTH,
height: K_HEIGHT,
left: -K_WIDTH / 2,
top: -K_HEIGHT / 2,

border: '5px solid #f44336',
borderRadius: K_HEIGHT,
backgroundColor: 'white',
textAlign: 'center',
color: '#3f51b5',
fontSize: 16,
fontWeight: 'bold',
padding: 4
};

class MyGreatPlace extends React.Component {

static propTypes = {
text: React.PropTypes.string
};

static defaultProps = {};

//shouldComponentUpdate = shouldPureComponentUpdate;

constructor(props) {
super(props);
}

render() {
return (
<div style={greatPlaceStyle}>
{this.props.text}
</div>
);
}
}
class SimpleMapPage extends React.Component {

static defaultProps = {
defaultCenter: {lat: 59.938043, lng: 30.337157},
zoom: 12,
greatPlaceCoords: {lat: 59.724465, lng: 30.080121}
};

//shouldComponentUpdate = shouldPureComponentUpdate;

constructor(props) {
super(props);
}

componentWillReceiveProps(nextProps) {
// console.log("test")
}

render() {
return (
<div style={divStyle}>
<GoogleMap
bootstrapURLKeys={{
key: '312312j3kl12j321random'
}}
center={this.props.center}
zoom={this.props.zoom}
defaultCenter={this.props.defaultCenter}
defaultZoom={this.props.zoom}
>
<MyGreatPlace lat={this.props.center.lat} lng={this.props.center.lng} text={'Site'} /* Kreyser Avrora */ />

</GoogleMap>
</div>
);
}
}

export default SimpleMapPage

最佳答案

对于 google-map-react 将样式放在选项中:

<GoogleMap
options={{
styles: [{ stylers: [{ 'saturation': 50 }, { 'gamma': 0.5 }] }]
}}>
</GoogleMap>

关于javascript - google-map-react 自定义皮肤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34991638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com