簡體   English   中英

如何更改谷歌地圖上圓半徑的顏色

[英]How to change the color of circle radius on google maps

我想在谷歌地圖上放置半徑圓。 我已經檢查了 google maps api docs,但仍然不知道該怎么做。

這是我的代碼:

 const MyMapComponent = compose(
          withProps({
            googleMapURL: googleMapsApiKey,
            loadingElement: <div style={mapConfigStyle.loadingElement} />,
            containerElement: <div style={mapConfigStyle.containerElement} />,
            mapElement: <div style={mapConfigStyle.mapElement} />
          }),
          withScriptjs,
          withGoogleMap,
        )(props => (
          <GoogleMap
            defaultZoom={12} 
            defaultCenter={{ lat: Number(this.state.latitude), lng: Number(this.state.longitude) }}

          >
         <Circle
          radius={1900}
          fillColor="#2a5777"
          center={{ lat: Number(this.state.latitude), lng: Number(this.state.longitude) }}
        />
            {props.isMarkerShown && (
              <Marker position={{ lat: Number(this.state.latitude), lng: Number(this.state.longitude) }} options={{ icon: { url: '/boost_marker.png' } }} />
            )}
          </GoogleMap>
<Circle
    defaultCenter={{
        lat: mapPosition.lat,
        lng: mapPosition.lng
    }}
    options={{fillColor:"#2a5777"}}                    
    radius={}
/>

將 fillColor 放入選項中

這對我有用

const options = {
        fillColor: color,
        strokeColor: color,
        strokeOpacity: 0.8,
        strokeWeight: 0.1,
        fillOpacity: 0.35,
        clickable: false,
        draggable: false,
        editable: false,
        visible: true,
        zIndex: 1
}

<Circle
    key={id}
    radius={1000}
    center={{
        lat: latitude,
        lng: longitude
    }}
    options={options}
/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM