I am using google-maps-react in my current application to show the map, here I have a requirement to display gradient Polygon, but i am unable to do so.
Currently these below attributes i can see from documentation.
我在我当前的应用程序中使用谷歌地图react来显示地图,这里我有一个显示梯度多边形的要求,但我无法做到。目前,我可以从文档中看到以下这些属性。
- fillColor
- fillOpacity
- strokeColor
- strokeOpacity
- strokePosition
- strokeWeight
I have also tried to add an an image url using below code but unable to do so, Can anyone please suggest me how can I achieve it?
我也尝试使用下面的代码添加一个图像url,但无法做到,有人能建议我如何实现吗?
import React, { Component } from 'react';
import { Map, GoogleApiWrapper, Polygon } from 'google-maps-react';
class MapContainer extends Component {
render() {
const triangleCoords = [
{ lat: 25.774, lng: -80.19 },
{ lat: 18.466, lng: -66.118 },
{ lat: 32.321, lng: -64.757 }
];
const polygonOptions = {
paths: triangleCoords,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
// Use the gradient image as the fillPattern
fillPattern: 'URL_TO_YOUR_GRADIENT_IMAGE',
};
return (
<Map
google={this.props.google}
zoom={10}
initialCenter={{ lat: 25.774, lng: -80.19 }}
>
<Polygon
paths={triangleCoords}
options={polygonOptions}
/>
</Map>
);
}
}
export default GoogleApiWrapper({
apiKey: 'YOUR_API_KEY'
})(MapContainer);
更多回答
There's no gradient option as of now, but you can file a feature request for it. Just make sure to put your use case. developers.google.com/maps/support#issue_tracker
目前还没有渐变选项,但你可以为它提交一个功能请求。只需确保放上你的用例。developers.google.com/maps/support#issue_tracker
优秀答案推荐
我是一名优秀的程序员,十分优秀!