小编pag*_*Und的帖子

在 google-maps-react 中使用折线?

我在我的反应程序中使用google-maps-react 。
有没有什么方法可以在绘制的标记之间绘制折线
任何内置方法来在标记之间绘制线条

react-google-maps

5
推荐指数
1
解决办法
9645
查看次数

在 react-google-maps 中添加航点

可编辑的示例代码如何在以下代码中使用航点 航点是否有助于绘制我在数据库中更新的方式,无论 ponits 将基于我更新的点

const DirectionsService = new google.maps.DirectionsService();
                 const  DirectionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true},{strokeColor:"#4a4a4a"});

      DirectionsService.route({

        origin: new google.maps.LatLng(this.state.orgin.latitude ,this.state.orgin.longitude),
         destination: new google.maps.LatLng(this.state.destination.latitude ,this.state.destination.longitude),
          travelMode: google.maps.TravelMode.DRIVING,

      }, 
       (result, status) => {
        if (status === google.maps.DirectionsStatus.OK) {
          this.setState({
            directions: result,
          });
        } else {
          console.error(`error fetching directions ${result}`);
        }
      });

            }).catch(function (err) {

            });

    }

  })

)(props =>
  <GoogleMap
    defaultZoom={50}>
     <DirectionsRenderer directions={props.directions}   />

  < Marker

  position={{  lat:props.delivery!=undefined?props.delivery.latitude:null, lng:  props.delivery!=undefined?props.delivery.longitude:null }} />

  </GoogleMap>

);
    return (
      <MapWithADirectionsRenderer />
    )
  }
Run Code Online (Sandbox Code Playgroud)

google-maps-api-3 react-google-maps

5
推荐指数
1
解决办法
3670
查看次数