react-native在IOS上集成百度地图详解

export default class BaiDuMapTest extends Component {

render() {

return (

);

}

}

const styles = StyleSheet.create({

container: {

flex: 1,

justifyContent: 'center',

alignItems: 'center',

backgroundColor: '#F5FCFF',

},

welcome: {

fontSize: 20,

textAlign: 'center',

margin: 10,

},

instructions: {

textAlign: 'center',

color: '#333333',

marginBottom: 5,

},

});

AppRegistry.registerComponent('BaiDuMapTest', () => BaiDuMapTest);

BaiduMapDemo.js

/**

  • @author lovebing

*/

import React, {

Component,

PropTypes

} from 'react';

import {

MapView,

MapTypes,

Geolocation

} from 'react-native-baidu-map';

import {

Button,

AppRegistry,

StyleSheet,

Text,

View,

TouchableHighlight

} from 'react-native';

import Dimensions from 'Dimensions';

export default class BaiduMapDemo extends Component {

constructor() {

super();

this.state = {

mayType: MapTypes.NORMAL,

zoom: 15,

center: {

longitude: 113.981718,

latitude: 22.542449

},

trafficEnabled: false,

baiduHeatMapEnabled: false,

markers: [{

longitude: 113.981718,

latitude: 22.542449,

title: "Window of the world"

},{

longitude: 113.995516,

latitude: 22.537642,

title: ""

}]

};

}

componentDidMount() {

}

render() {

return (

<MapView

trafficEnabled={this.state.trafficEnabled}

baiduHeatMapEnabled={this.state.baiduHeatMapEnabled}

zoom={this.state.zoom}

mapType={this.state.mapType}

center={this.state.center}

marker={this.state.marker}

markers={this.state.markers}

style={styles.map}

onMarkerClick={(e) => {

console.warn(JSON.stringify(e));

}}

onMapClick={(e) => {

}}

<Button title="Normal" onPress={() => {

this.setState({

mapType: MapTypes.NORMAL

});

}} />

<Button style={styles.btn} title="Satellite" onPress={() => {

this.setState({

mapType: MapTypes.SATELLITE

});

}} />

<Button style={styles.btn} title="Locate" onPress={() => {

console.warn('center', this.state.center);

Geolocation.getCurrentPosition()

.then(data => {

console.warn(JSON.stringify(data));

this.setState({

zoom: 15,

marker: {

latitude: data.latitude,

longitude: data.longitude,

title: 'Your location'

},

center: {

latitude: data.latitude,

longitude: data.longitude,

rand: Math.random()

}

});

})

.catch(e =>{

console.warn(e, 'error');

})

}} />

<Button title="Zoom+" onPress={() => {

this.setState({

zoom: this.state.zoom + 1

});

}} />

<Button title="Zoom-" onPress={() => {

if(this.state.zoom > 0) {

this.setState({

zoom: this.state.zoom - 1

});

}

}} />

<Button title="Traffic" onPress={() => {

this.setState({

trafficEnabled: !this.state.trafficEnabled

});

}} />

<Button title="Baidu HeatMap" onPress={() => {

this.setState({

baiduHeatMapEnabled: !this.state.baiduHeatMapEnabled

});

}} />

);

}

}

const styles = StyleSheet.create({

row: {

flexDirection: 'row',

height: 40

},

container: {

flex: 1,

justifyContent: 'flex-start',

web浏览器中的javascript

  • 客户端javascript
  • 在html里嵌入javascript
  • javascript程序的执行
  • 兼容性和互用性
  • 可访问性
  • 安全性
  • 客户端框架

window对象

  • 计时器

  • 浏览器定位和导航

  • 浏览历史

  • 浏览器和屏幕信息

  • 对话框

  • 错误处理

  • 作为window对象属性的文档元素

相关推荐
Johnny Tong11 小时前
iOS 获取设备占用内存
ios·内存·host_vm
木兰不吃草11 小时前
如何在 Mac 上下载安装仙剑游戏仙剑世界?可以通过IPA砸壳包安装非常简单
游戏·macos·ios·游戏程序·mac
帅次11 小时前
Flutter 异步编程利器:Future 与 Stream 深度解析
android·flutter·ios·小程序·kotlin·webview·android-studio
小鹿撞出了脑震荡14 小时前
Effective Objective-C 2.0 读书笔记——大中枢派发
开发语言·ios·objective-c
struggle202515 小时前
Ollmao (OH-luh-毛程序包及源码) 是一款原生 SwiftUI 应用程序,它与 Ollama 集成,可在 Mac 上本地运行强大的 AI 模型
ios·swiftui·swift
神仙别闹1 天前
基于IOS实现各种倒计时功能
macos·ios·cocoa
gp1031 天前
iOS事件传递和响应
ios·响应链·事件传递
SunshineBrother2 天前
Flutter go_router 路由管理详解&封装
android·flutter·ios
倾云鹤3 天前
iOS实现生物识别
ios·生物识别
柚鸥ASO优化3 天前
适用于iOS的应用商店优化(ASO)清单
ios·aso优化