React Native Mapbox GL

码农软件 · 软件分类 · 手机开发包 · 2019-05-05 15:26:42

软件介绍

React Native Mapbox GL 是绑定 Mapbox GL 地图的 React Native 组件。

安装:

npm install react-native-mapbox-gl --save

示例:

'use strict';
var React = require('react-native');
var MapboxGLMap = require('react-native-mapbox-gl');
var mapRef = 'mapRef';
var {
  AppRegistry,
  StyleSheet,
  View,
  Text,
  StatusBarIOS,
} = React;
var map = React.createClass({
  mixins: [MapboxGLMap.Mixin],
  getInitialState() {
    return {
      mapLocation: {
        latitude: 0,
        longitude: 0
       },
       center: {
         latitude: 40.72052634,
         longitude: -73.97686958312988
       },
       zoom: 11,
       direction: 40,
       annotations: [{
         latitude: 40.72052634,
         longitude:  -73.97686958312988,
         title: 'This is marker 1',
       },{
         latitude: 40.714541341726175,
         longitude:  -74.00579452514648,
         subtitle: 'Neat, this is a subtitle'
       }]
     }
  },
  onChange(e) {
    this.setState({ currentZoom: e.zoom });
  },
  onUpdateUserLocation(location) {
    console.log(location)
  },
  onOpenAnnotation(annotation) {
    console.log(annotation)
  },
  render: function() {
    StatusBarIOS.setHidden(true);
    return (
      <View style={styles.container}>
       <Text style={styles.text} onPress={() => this.setDirectionAnimated(mapRef, 0)}>
         Set direction to 0
       </Text>
       <Text style={styles.text} onPress={() => this.setZoomLevelAnimated(mapRef, 6)}>
        Zoom out to zoom level 6
      </Text>
       <Text style={styles.text} onPress={() => this.setCenterCoordinateAnimated(mapRef, 48.8589, 2.3447)}>
        Go to Paris at current zoom level {parseInt(this.state.currentZoom)}
      </Text>
      <Text style={styles.text} onPress={() => this.setCenterCoordinateZoomLevelAnimated(mapRef, 35.68829, 139.77492, 14)}>
       Go to Tokyo at fixed zoom level 14
     </Text>
     <Text style={styles.text} onPress={() => this.addAnnotations(mapRef, [{
       latitude: 40.73312,
       longitude:  -73.989,
       title: 'This is a new marker',
     }])}>
      Add new marker
    </Text>
       <MapboxGLMap
         style={styles.map}
         direction={10}
         rotateEnabled={true}
         showsUserLocation={true}
         ref={mapRef}
         accessToken={'your-mapbox.com-access-token'}
         styleURL={'asset://styles/mapbox-streets-v7.json'}
         centerCoordinate={this.state.center}
         userLocationVisible={true}
         zoomLevel={this.state.zoom}
         onRegionChange={this.onChange}
         annotations={this.state.annotations}
         onOpenAnnotation={this.onOpenAnnotation}
         onUpdateUserLocation={this.onUpdateUserLocation}/>
      </View>
    );
  }
});
var styles = StyleSheet.create({
  container: {
    flexDirection: 'column',
    flex: 1
  },
  map: {
    flex:5,
  },
  text: {
    padding: 2
  }
});
AppRegistry.registerComponent('yourProjectName', () => map);


本文地址:https://codercto.com/soft/d/5082.html

计算机图形学

计算机图形学

[美]PeterShirley / 高春晓、赵清杰、张文耀 / 人民邮电出版社 / 2007-6 / 49.00元

本书是国外高校采用率很高的计算机图形学教材,共分为26章,全面系统地讲解了计算机图形学的基本概念和相关技术。书中先介绍图形学相关的数学知识,然后依次讲解图形学的光栅算法、三三维观察、隐藏面消除、光照、纹理、绘制等算法和理论,并介绍可视感知、计算机动画、基于图像的绘制、可视化以及构建交互式图形应用等。 本书可作为信息技术等相关专业本科生、研究生计算机图形学课程的教材,也可以作为计算机图形学工作......一起来看看 《计算机图形学》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具