react-native试玩(9)-地图视图
发布时间:2020-12-15 04:49:05 所属栏目:百科 来源:网络整理
导读:MapView 属性 名称 类型 意义 默认 annotations [{latitude: number,longitude: number,animateDrop: bool,title: string,subtitle: string,hasLeftCallout: bool,hasRightCallout: bool,onLeftCalloutPress: function,onRightCalloutPress: function,id: st
属性
实例默认首先我们来显示一张默认的地图: 'use strict';
var React = require('react-native');
var {
AppRegistry,StyleSheet,View,MapView,} = React;
var helloworld = React.createClass({
render: function() {
return (
<MapView style={{ height: 150,margin: 10,borderWidth: 1,borderColor: '#000000',}} /> ); },}); var styles = StyleSheet.create({ }); AppRegistry.registerComponent('hellowrold',() => helloworld);
默认情况下,我们需要设置MapView控件的 上面的图显示我们在美国(vpn的作用),但是这个地图还是很龊的。需要我们一步一步去修善。 zoomEnabled缩放,放大属性,默认是为true,所以,我们在上面的例子中,双击就能达到放大的作用。如果你将 scrollEnabled拖拽,默认该属性为 showsUserLocation发送位置信息,默认该属性为 mapTypestandard<MapView style={{ height: 600,margin: 10,borderWidth: 1,borderColor: '#000000',}} zoomEnabled={true} scrollEnabled={true} showsUserLocation={true} mapType='standard' />
默认就为该属性,所以显示的效果也没啥变化: satellite<MapView style={{ height: 600,}} zoomEnabled={true} scrollEnabled={true} showsUserLocation={true} mapType='satellite' />
hybrid<MapView style={{ height: 600,}} zoomEnabled={true} scrollEnabled={true} showsUserLocation={true} mapType='hybrid' />
就比 legalLabelInsets设置Legal标签的位置,默认在是左下角,我们可以将其移到左上角: <MapView style={{ height: 600,}} zoomEnabled={true} scrollEnabled={true} showsUserLocation={true} mapType='hybrid' pitchEnabled={true} rotateEnabled={true} legalLabelInsets={{top:20,left:20}} /> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |