Reactjs 反应本机谷歌地图多线阴影?

Reactjs 反应本机谷歌地图多线阴影?,reactjs,react-native,google-maps,Reactjs,React Native,Google Maps,我已经在react native中构建了基于地图的应用程序。我正在使用react原生谷歌地图库来实现这一点。我一直在寻找我的两个问题的答案?我想不出如何解决这些问题 如何向多段线添加阴影 如何使多段线从给定的标记开始 下面是截图,它们可能会帮助你理解我的意思 您提到您正在使用react原生谷歌地图库。你是说图书馆吗?如果是的话,你试过这个方法吗?可以更改多段线的笔划属性,但不能添加阴影。如果愿意,可以使用相同的坐标(路径)创建另一条多段线,并更改看起来像多段线阴影的笔划特性。也可以将此多段线的

我已经在react native中构建了基于地图的应用程序。我正在使用react原生谷歌地图库来实现这一点。我一直在寻找我的两个问题的答案?我想不出如何解决这些问题

  • 如何向多段线添加阴影
  • 如何使多段线从给定的标记开始
  • 下面是截图,它们可能会帮助你理解我的意思


    您提到您正在使用react原生谷歌地图库。你是说图书馆吗?如果是的话,你试过这个方法吗?可以更改多段线的笔划属性,但不能添加阴影。如果愿意,可以使用相同的坐标(路径)创建另一条多段线,并更改看起来像多段线阴影的笔划特性。也可以将此多段线的坐标设置为从特定坐标或标记开始和结束

    下面是一个示例和代码片段:

    import React, { Component } from 'react';
    import { Text, View, StyleSheet, Dimensions } from 'react-native';
    import MapView, { Marker, Polyline } from 'react-native-maps';
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center',
      },
      map: {
        width: Dimensions.get('window').width,
        height: Dimensions.get('window').height,
      },
    });
    
    class MapApp extends Component {
      constructor(props) {
        super(props);
        this.state = {
          coords: [
            { latitude: 37.7948605, longitude: -122.4596065 },
            { latitude: 37.8025259, longitude: -122.4351431 },
          ],
        };
      }
    
      render() {
        return (
          <View style={styles.container}>
            <MapView
              style={styles.map}
              initialRegion={{
                latitude: 37.7948605,
                longitude: -122.4596065,
                latitudeDelta: 0.0922,
                longitudeDelta: 0.0421,
              }}>
              {this.state.coords.map((coords, index) => (
                <Marker key={index} coordinate={coords} />
              ))}
    
              <Polyline
                coordinates={this.state.coords}
                //strokeColor="#000" // fallback for when `strokeColors` is not supported by the map-provider
                strokeColor={'rgb(0, 0, 0)'}
                strokeWidth={6}
              />
              <Polyline
                coordinates={this.state.coords}
                //this is the polyline for shadow
                strokeColor={'rgba(0, 0, 0,0.3)'}
                strokeWidth={15}
              />
            </MapView>
          </View>
        );
      }
    }
    
    export default MapApp;
    
    import React,{Component}来自'React';
    从“react native”导入{文本、视图、样式表、维度};
    从“react native maps”导入MapView,{Marker,Polyline};
    const styles=StyleSheet.create({
    容器:{
    弹性:1,
    背景颜色:“#fff”,
    对齐项目:“居中”,
    为内容辩护:“中心”,
    },
    地图:{
    宽度:尺寸。获取('窗口')。宽度,
    高度:尺寸。获取(“窗口”)。高度,
    },
    });
    类MapApp扩展组件{
    建造师(道具){
    超级(道具);
    此.state={
    协调:[
    {纬度:37.7948605,经度:-122.4596065},
    {纬度:37.8025259,经度:-122.4351431},
    ],
    };
    }
    render(){
    返回(
    {this.state.coords.map((coords,index)=>(
    ))}
    );
    }
    }
    导出默认MapApp;