zoukankan      html  css  js  c++  java
  • react native中地图组件的选择(react-native-amap3d)

    需求 : react-native项目中需要使用高德地图组件;有基本的轨迹以及marker功能;
    • react-native-amap-geolocation
    • react-native-smart-amap
    • react-native-amap3d
    • react-native-maps

      对比了一些,感觉比较全的还是react-native-community的react-native-maps ;but没找到其可以使用高德地图,只能使用Google map?!!于是,只好选其他的了,最终选择了eact-native-amap3d,效果以及简单使用如下:
    
    import React, {Component} from 'react';
    import {Platform, StyleSheet, View} from 'react-native';
    import { MapView,Marker,Polyline,Polygon } from 'react-native-amap3d';
    
    var Dimensions = require('Dimensions');
    const deviceHeight = Dimensions.get("window").height;
    const deviceWidth = Dimensions.get("window").width;
    
    
    
    class CarDetailsPage extends Component {
      constructor(props) {
        super(props);
        console.disableYellowBox = true;
        this.state = {
        //****
        };
      }
      componentWillMount () {  
      }
    
     
      render() {  
        return (
          <Container>
            <View style={{ flex: 1 }}>
              <MapView
                draggable
                  coordinate={ {
                      latitude: 40.006901,
                      longitude: 116.097972,
                    }}
                  mapType={'standard'}
                  zoomLevel={12}
                  zoomEnabled={true}
                  scrollEnabled={true}
                  rotateEnabled={true}
                  style={styles.mapStyles}
                  showsZoomControls={false}
                  zoomLevel={15}
              >      
        
    			//画marker 
                <Marker 
                  key={navigation.getParam('currentCarName','')}
                  active
                  title={navigation.getParam('currentCarName','')}
                  color='blue'
                  description={'battery:'+this.props.carwebsocket.carstatus.battery}
                  coordinate={ {
                      latitude: 40.006901,
                      longitude: 116.097972,
                    }}/>
                     
            	
            	//画框
                <Polygon 
                coordinates={gps} 
                fillColor={'transparent'} 
                strokeColor={'#1398E2'} 
                strokeWidth={4}
                ></Polygon>  
                     
                //画线条
                <Polyline
                  width={10}
                  color='rgba(255, 0, 0, 0.5)'
                  
                  coordinates={[
                    {
                      latitude: 40.006901,
                      longitude: 116.097972,
                    },
                    {
                      latitude: 40.006901,
                      longitude: 116.597972,
                    },
                    {
                      latitude: 39.706901,
                      longitude: 116.597972,
                    },
                  ]}
                />      
               
    
              </MapView>
             
      
    
             </View>
          </Container>
        );
      }
    }
    const styles = {
      mapStyles:{
        height:deviceHeight,
        deviceWidth
      }
    }
    
    export default CarDetailsPage;
    

    虽然react-native-amap3d个人觉得稍微有些组件不够丰富完善,有些遗憾;但是基础功能是够用的,以及配置使用还是比较方便的

  • 相关阅读:
    Kubernetes+Docker+Istio 容器云实践
    SDN网络IPv6组播机制支持实时视频业务海量用户扩展
    如何运用结构化思维进行故障处理
    UAVStack JVM监控分析工具:图形化展示采集及分析监控数据
    个性化推荐产品功能的设计和B端产品的功能策划方式
    Kubernetes监控实践(2):可行监控方案之Prometheus和Sensu
    demo演示如何写一个无配置格式统一的日志
    指尖前端重构(React)技术调研分析
    学习设计模式前传
    我是码农要翻身
  • 原文地址:https://www.cnblogs.com/smileyqp/p/12675356.html
Copyright © 2011-2022 走看看