Code Monkey home page Code Monkey logo

react-native-baidumap-sdk's Introduction

注意:该项目已暂停维护

react-native-baidumap-sdk npm version build status

React Native BaiduMap SDK for Android + iOS.

你可以下载安装 example.apk 看看实际中的效果。

安装

用法

基本用法

import { MapView } from 'react-native-baidumap-sdk'

render() {
  return <MapView center={{ latitude: 39.2, longitude: 112.4 }} />
}

显示卫星图

<MapView satellite />

监听地图事件

import { MapView } from 'react-native-baidumap-sdk'

render() {
  return (
    <MapView
      onLoad={() => console.log('onLoad')}
      onClick={point => console.log(point)}
      onStatusChange={status => console.log(status)}
    />
  )
}

定位并关联定位图层

import { MapView, Location } from 'react-native-baidumap-sdk'

await Location.init()
Location.addLocationListener(location => this.setState({ location }))
Location.start()

state = { location: null }

render() {
  return <MapView location={this.state.location} locationEnabled />
}

添加标记

<MapView>
  <MapView.Marker
    color="#2ecc71"
    title="This is a marker"
    onPress={this.onPress}
  />
</MapView>

添加自定义图片标记

<MapView>
  <MapView.Marker
    title="This is a image marker"
    image="flag"
    coordinate={{ latitude: 39, longitude: 113 }}
  />
</MapView>

添加自定义 View 标记

<MapView>
  <MapView.Marker
    icon={() => (
      <View>
        <Image source={image} />
        <Text>This is a custom marker</Text>
      </View>
    )}
  />
</MapView>

点聚合

onStatusChange = status => this.cluster.update(status)

renderMarker = item => (
  <MapView.Marker
    key={item.extra.key}
    coordinate={item.coordinate}
  />
)

render() {
  return (
    <MapView onStatusChange={this.onStatusChange}>
      <MapView.Cluster
        ref={ref => this.cluster = ref}
        markers={this.markers}
        renderMarker={this.renderMarker}
      />
    </MapView>
  )
}

显示热力图

points = [
  {
    latitude: 39,
    longitude: 113,
    intensity: 16,
  },
  ...
]

<MapView>
  <MapView.HeatMap
    points={this.points}
    radius={20}
    opacity={0.5}
  />
</MapView>

地理编码/逆地理编码

import { Geocode } from 'react-native-baidumap-sdk'

const searchResult = await Geocode.search('海龙大厦')
const reverseResult = await Geocode.reverse({ latitude: 39, longitude: 113 })

需要注意,以上例子简写了一些属性,并不能直接使用,更多实际的例子请参考:example

接口文档

react-native-baidumap-sdk's People

Contributors

liaoyinglong avatar qiuxiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-baidumap-sdk's Issues

MapView 点击添加marker的问题

问题描述:在MapView中点击一点然后将Marker定在该点(只有一个Marker)
预期效果:点击后Marker出现在点击的点
实际效果:点击后Marker位置并没有变动,拖拽地图移动后Marker才能显示在指定的位置
代码如下:`import React, {Component} from 'react'
import {Alert, StyleSheet} from 'react-native'
import {MapView} from 'react-native-baidumap-sdk'

export default class Dynamic extends Component {
static navigationOptions = {title: 'Dynamically add and remove'}

constructor(props){
    super(props)
    this.state = {
        coordinate : {}
    }
}


addMarker = (coordinate) => {
    this.setState({
        coordinate
    })
}


render() {
    return (
        <MapView style={StyleSheet.absoluteFill} onClick={this.addMarker} >
            {
                this.state.coordinate.latitude ? (
                    <MapView.Marker coordinate={this.state.coordinate}/>
                ) : null
            }
        </MapView>
    )
}

}`

200e109f-3b82-4b0c-8d76-1b543933b1d2

百度地图只有空白网格

百度地图只有空白网格,感觉应该是百度AK的原因,但弄了半天也弄不出来,求帮忙,感觉keystore没有作用啊

打包报错

qq20180311-160124
node_modules/react-native-baidumap-sdk/lib/js/map-view/text.js

关于离线地图

我在高德的那个组件下看到有离线的功能,百度地图下是没有加吗

新增 SDKInitializer 模块

一方面,可以让开发者自行选择初始化的时间。另一方面,提供初始化结果通知,以便更好地定位开发密钥问题。

关于定位返回信息

您好,我有个问题:
1.定位是返回的信息能否含有地址等详细信息,不只是经纬度

2.获取定位信息的详细地址是否只能通过Geocode.reverse获取

谢谢!!!
文字有点多不会英文了,sorry

集成地图后,应用的大小

已解决:是因为导入的时候,把一些没用的东西导入进来了。。。

集成地图后,应用的大小:安卓增加7M,ios增加3M,在正常范围内。

但是这里我是手动拖入地图SDk的,我 pod install 不知道为啥没办法导入 framework ,估计自己项目里不知道哪里配置错了。

感谢作者的开源,真心不错。😁

====================================

原问题

安卓

原先18.5M,集成后25.6M,增加了7M,在可接受范围内。

IOS

原先21M,集成后122.1M,增加了100M,好像有点大了。

是不是因为我下载并导入了整个的百度地图sdk,但是如果我不导入,就会出现这个错误 #48

MapView.marker android报错:width and height must be > 0

<MapView.Marker
      key={index}
      view={() => <Icon name="start" />}
      coordinate={{ latitude: item.latitude, longitude: item.longitude }}
    />

我创建了一个页面组件MapDetail包含如上代码。

  • 当我给MapView.Marker添加view属性时
  • 导航使用react navigation
  • 当直接从Home页面导航进入MapDetail页面一切正常
  • 当通过某一个列表页的某一项点击导航进入MapDetail则报错
width and height must be > 0

createBitmap
Bitmap.java:841
createBitmap
Bitmap.java:820
...

安卓端在初始化时报错 permission check error

在执行 Initializer.init('XXX').catch(e => console.error(e)) 这句时报错 permission check error

04-19 21:35:21.735 7795 7826 E ReactNativeJS: { [Error: permission check error] framesToPop: 1, code: '101' }

Polyline 能否支持官方文档中的添加纹理以及绘制虚线的功能

折线类为 BMKPolyline,由一组经纬度坐标组成,并以有序序列形式建立一系列的线段。

iOS SDK支持在3D矢量地图上绘制带箭头或有纹理等样式的折线,同时可设置折线端点和连接点的类型,以满足各种绘制线的场景。支持虚线或者纹理图片绘制折线。

这段是iOS SDK的文档中对Polyline的介绍,我们可以通过什么样的方式做到一样的事情吗

ios bitcode

什么时候能升级以下sdk版本,目前的版本不支持bitcode,无法打包

为什么我的安装完了,运行就出现错误

我的RN版本 0.46.4 运行出现下面错误

src\main\java\cn\qiuxiang\react\baidumap\BaiduMapPackage.kt: (12, 1): Class 'B
aiduMapPackage' is not abstract and does not implement abstract member public ab
stract fun createJSModules(): (Mutable)List<Class<out JavaScriptModule!>!>! defi
ned in com.facebook.react.ReactPackage
:react-native-baidumap-sdk:compileReleaseKotlin FAILED

FAILURE: Build failed with an exception.

地图空白只显示网格(真机和Genymotion模拟器下都是这种情况)

地图空白只显示网格(真机和Genymotion模拟器下都是这种情况)
{
"name": "qiuxiangbdmapexample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-baidumap-sdk": "^0.3.2",
"react-navigation": "^1.1.2"
},
"devDependencies": {
"babel-jest": "22.4.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.0",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}

_20180222172344

Attempt to invoke virtual method

qq 20180507100548

rn 0.55.3
react-native-baidumap-sdk: 0.5.4

在不使用 Initializer.init这个方法时,能获取到定位的经纬度,去换取具体城市时取不到。就加了这个init方法就报错了

附近的圆圈问题

这个圆圈设置颜色后会一直往上铺,颜色会越来越深
<MapView.Circle
center={this.state.circleCenter}
radius={500}
strokeWidth={1}
strokeColor="rgba(162, 165, 167, 1.0)"
fillColor="rgba(0, 0, 0, 0)"
/>
就是这个

使用Pod install 后 安装react-native-baidumap-sdk失败

使用Pod 安装其他第三方包可以
安装这个包 会显示
Downloading dependencies
Installing BaiduMapKit (3.4.4)
持续很长时间然后显示失败

Git download
Git download
$ /usr/bin/git clone https://github.com/BaiduLBS/BaiduMapKit.git /var/folders/09/ws9x9qcx0vnd2g04w59lh7jc0000gn/T/d20180329-50121-iqqyjz
--template= --single-branch --depth 1 --branch 3.4.4
Cloning into '/var/folders/09/ws9x9qcx0vnd2g04w59lh7jc0000gn/T/d20180329-50121-iqqyjz'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

[!] Error installing BaiduMapKit
[!] /usr/bin/git clone https://github.com/BaiduLBS/BaiduMapKit.git /var/folders/09/ws9x9qcx0vnd2g04w59lh7jc0000gn/T/d20180329-50121-iqqyjz --template= --single-branch --depth 1 --branch 3.4.4

Cloning into '/var/folders/09/ws9x9qcx0vnd2g04w59lh7jc0000gn/T/d20180329-50121-iqqyjz'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.