Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-amap3d
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-amap3d
Commits
675efab5
Commit
675efab5
authored
Dec 23, 2017
by
7c00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 android 像素单位处理
parent
05b9a735
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
39 additions
and
80 deletions
+39
-80
build.gradle
android/build.gradle
+1
-1
AMapUtilsModule.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapUtilsModule.kt
+1
-1
AMapCircleManager.kt
...n/java/cn/qiuxiang/react/amap3d/maps/AMapCircleManager.kt
+2
-1
AMapMarker.kt
...src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarker.kt
+2
-2
AMapPolygonManager.kt
.../java/cn/qiuxiang/react/amap3d/maps/AMapPolygonManager.kt
+3
-2
AMapPolylineManager.kt
...java/cn/qiuxiang/react/amap3d/maps/AMapPolylineManager.kt
+2
-1
examples.js
example/src/examples.js
+2
-2
Circle.js
src/maps/Circle.js
+6
-21
HeatMap.js
src/maps/HeatMap.js
+5
-12
InfoWindow.js
src/maps/InfoWindow.js
+0
-7
Marker.js
src/maps/Marker.js
+5
-1
MultiPoint.js
src/maps/MultiPoint.js
+1
-1
Polygon.js
src/maps/Polygon.js
+6
-21
Polyline.js
src/maps/Polyline.js
+3
-7
No files found.
android/build.gradle
View file @
675efab5
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
buildscript
{
buildscript
{
ext
.
kotlin_version
=
'1.
1.51
'
ext
.
kotlin_version
=
'1.
2.0
'
repositories
{
repositories
{
jcenter
()
jcenter
()
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapUtilsModule.kt
View file @
675efab5
...
@@ -20,5 +20,5 @@ class AMapUtilsModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
...
@@ -20,5 +20,5 @@ class AMapUtilsModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
}
}
}
}
val
In
t
.
toPx
:
Int
val
Floa
t
.
toPx
:
Int
get
()
=
(
this
*
Resources
.
getSystem
().
displayMetrics
.
density
).
toInt
()
get
()
=
(
this
*
Resources
.
getSystem
().
displayMetrics
.
density
).
toInt
()
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapCircleManager.kt
View file @
675efab5
package
cn.qiuxiang.react.amap3d.maps
package
cn.qiuxiang.react.amap3d.maps
import
cn.qiuxiang.react.amap3d.toPx
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.LatLng
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.SimpleViewManager
...
@@ -40,7 +41,7 @@ internal class AMapCircleManager : SimpleViewManager<AMapCircle>() {
...
@@ -40,7 +41,7 @@ internal class AMapCircleManager : SimpleViewManager<AMapCircle>() {
@ReactProp
(
name
=
"strokeWidth"
)
@ReactProp
(
name
=
"strokeWidth"
)
fun
setStrokeWidth
(
circle
:
AMapCircle
,
strokeWidth
:
Float
)
{
fun
setStrokeWidth
(
circle
:
AMapCircle
,
strokeWidth
:
Float
)
{
circle
.
strokeWidth
=
strokeWidth
circle
.
strokeWidth
=
strokeWidth
.
toPx
.
toFloat
()
}
}
@ReactProp
(
name
=
"zIndex"
)
@ReactProp
(
name
=
"zIndex"
)
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapMarker.kt
View file @
675efab5
...
@@ -162,8 +162,8 @@ class AMapMarker(context: Context) : ReactViewGroup(context), AMapOverlay {
...
@@ -162,8 +162,8 @@ class AMapMarker(context: Context) : ReactViewGroup(context), AMapOverlay {
fun
lockToScreen
(
args
:
ReadableArray
?)
{
fun
lockToScreen
(
args
:
ReadableArray
?)
{
if
(
args
!=
null
)
{
if
(
args
!=
null
)
{
val
x
=
args
.
get
Int
(
0
).
toPx
val
x
=
args
.
get
Double
(
0
).
toFloat
(
).
toPx
val
y
=
args
.
get
Int
(
1
).
toPx
val
y
=
args
.
get
Double
(
1
).
toFloat
(
).
toPx
marker
?.
setPositionByPixels
(
x
,
y
)
marker
?.
setPositionByPixels
(
x
,
y
)
}
}
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolygonManager.kt
View file @
675efab5
package
cn.qiuxiang.react.amap3d.maps
package
cn.qiuxiang.react.amap3d.maps
import
cn.qiuxiang.react.amap3d.toPx
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
...
@@ -32,11 +33,11 @@ internal class AMapPolygonManager : SimpleViewManager<AMapPolygon>() {
...
@@ -32,11 +33,11 @@ internal class AMapPolygonManager : SimpleViewManager<AMapPolygon>() {
@ReactProp
(
name
=
"strokeWidth"
)
@ReactProp
(
name
=
"strokeWidth"
)
fun
setStrokeWidth
(
polygon
:
AMapPolygon
,
strokeWidth
:
Float
)
{
fun
setStrokeWidth
(
polygon
:
AMapPolygon
,
strokeWidth
:
Float
)
{
polygon
.
strokeWidth
=
strokeWidth
polygon
.
strokeWidth
=
strokeWidth
.
toPx
.
toFloat
()
}
}
@ReactProp
(
name
=
"zIndex"
)
@ReactProp
(
name
=
"zIndex"
)
fun
setZ
Index_
(
polygon
:
AMapPolygon
,
zIndex
:
Float
)
{
fun
setZ
index
(
polygon
:
AMapPolygon
,
zIndex
:
Float
)
{
polygon
.
zIndex
=
zIndex
polygon
.
zIndex
=
zIndex
}
}
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/maps/AMapPolylineManager.kt
View file @
675efab5
package
cn.qiuxiang.react.amap3d.maps
package
cn.qiuxiang.react.amap3d.maps
import
cn.qiuxiang.react.amap3d.toPx
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.SimpleViewManager
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.ThemedReactContext
...
@@ -36,7 +37,7 @@ internal class AMapPolylineManager : SimpleViewManager<AMapPolyline>() {
...
@@ -36,7 +37,7 @@ internal class AMapPolylineManager : SimpleViewManager<AMapPolyline>() {
@ReactProp
(
name
=
"width"
)
@ReactProp
(
name
=
"width"
)
fun
setWidth
(
polyline
:
AMapPolyline
,
width
:
Float
)
{
fun
setWidth
(
polyline
:
AMapPolyline
,
width
:
Float
)
{
polyline
.
width
=
width
polyline
.
width
=
width
.
toPx
.
toFloat
()
}
}
@ReactProp
(
name
=
"zIndex"
)
@ReactProp
(
name
=
"zIndex"
)
...
...
example/src/examples.js
View file @
675efab5
...
@@ -43,8 +43,6 @@ export default class Examples extends Component {
...
@@ -43,8 +43,6 @@ export default class Examples extends Component {
{
this
.
_renderItem
(
'动画移动'
,
'Animated'
)}
{
this
.
_renderItem
(
'动画移动'
,
'Animated'
)}
<
View
style
=
{
styles
.
separator
}
/
>
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'地图事件'
,
'Events'
)}
{
this
.
_renderItem
(
'地图事件'
,
'Events'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'离线地图'
,
'Offline'
)}
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
group
}
>
<
View
style
=
{
styles
.
group
}
>
{
this
.
_renderItem
(
'添加标记'
,
'Marker'
)}
{
this
.
_renderItem
(
'添加标记'
,
'Marker'
)}
...
@@ -61,6 +59,8 @@ export default class Examples extends Component {
...
@@ -61,6 +59,8 @@ export default class Examples extends Component {
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
group
}
>
<
View
style
=
{
styles
.
group
}
>
{
this
.
_renderItem
(
'导航'
,
'Navigation'
)}
{
this
.
_renderItem
(
'导航'
,
'Navigation'
)}
<
View
style
=
{
styles
.
separator
}
/
>
{
this
.
_renderItem
(
'离线地图'
,
'Offline'
)}
<
/View
>
<
/View
>
<
/ScrollView
>
<
/ScrollView
>
}
}
...
...
src/maps/Circle.js
View file @
675efab5
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
PixelRatio
,
Platform
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
ColorPropType
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
import
{
LatLng
}
from
'../PropTypes'
export
default
class
Circle
extends
PureComponent
{
export
default
requireNativeComponent
(
'AMapCircle'
,
{
static
propTypes
=
{
propTypes
:
{
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
...
@@ -25,30 +24,16 @@ export default class Circle extends PureComponent {
...
@@ -25,30 +24,16 @@ export default class Circle extends PureComponent {
/**
/**
* 边线颜色
* 边线颜色
*/
*/
strokeColor
:
PropTypes
.
string
,
strokeColor
:
ColorPropType
,
/**
/**
* 填充颜色
* 填充颜色
*/
*/
fillColor
:
PropTypes
.
string
,
fillColor
:
ColorPropType
,
/**
/**
* 层级
* 层级
*/
*/
zIndex
:
PropTypes
.
number
,
zIndex
:
PropTypes
.
number
,
}
render
()
{
const
props
=
{
...
this
.
props
,
...
Platform
.
select
({
android
:
{
strokeWidth
:
PixelRatio
.
getPixelSizeForLayoutSize
(
this
.
props
.
strokeWidth
),
},
},
}),
})
}
return
<
AMapCircle
{...
props
}
/
>
}
}
const
AMapCircle
=
requireNativeComponent
(
'AMapCircle'
,
Circle
)
src/maps/HeatMap.js
View file @
675efab5
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
PixelRatio
,
Platform
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
import
{
LatLng
}
from
'../PropTypes'
/**
/**
* 注意,热力图组件的 props 设置过一次之后便不能再更改
* 注意,热力图组件的 props 设置过一次之后便不能再更改
*/
*/
export
default
class
HeatMap
extends
PureComponent
{
export
default
requireNativeComponent
(
'AMapHeatMap'
,
{
static
propTypes
=
{
propTypes
:
{
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
...
@@ -24,11 +23,5 @@ export default class HeatMap extends PureComponent {
...
@@ -24,11 +23,5 @@ export default class HeatMap extends PureComponent {
* 透明度
* 透明度
*/
*/
opacity
:
PropTypes
.
number
,
opacity
:
PropTypes
.
number
,
}
},
})
render
()
{
return
<
AMapHeatMap
{...
this
.
props
}
/
>
}
}
const
AMapHeatMap
=
requireNativeComponent
(
'AMapHeatMap'
,
HeatMap
)
src/maps/InfoWindow.js
deleted
100644 → 0
View file @
05b9a735
import
{
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
export
default
requireNativeComponent
(
'AMapInfoWindow'
,
{
propTypes
:
{
...
ViewPropTypes
,
}
})
src/maps/Marker.js
View file @
675efab5
import
React
from
'react'
import
React
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
Platform
,
requireNativeComponent
,
StyleSheet
,
ViewPropTypes
,
View
}
from
'react-native'
import
{
Platform
,
requireNativeComponent
,
StyleSheet
,
ViewPropTypes
,
View
}
from
'react-native'
import
InfoWindow
from
'./InfoWindow'
import
{
LatLng
,
Point
}
from
'../PropTypes'
import
{
LatLng
,
Point
}
from
'../PropTypes'
import
BaseComponent
from
'../BaseComponent'
import
BaseComponent
from
'../BaseComponent'
...
@@ -174,6 +173,11 @@ export default class Marker extends BaseComponent {
...
@@ -174,6 +173,11 @@ export default class Marker extends BaseComponent {
}
}
const
AMapMarker
=
requireNativeComponent
(
'AMapMarker'
,
Marker
)
const
AMapMarker
=
requireNativeComponent
(
'AMapMarker'
,
Marker
)
const
InfoWindow
=
requireNativeComponent
(
'AMapInfoWindow'
,
{
propTypes
:
{
...
ViewPropTypes
,
}
})
const
style
=
StyleSheet
.
create
({
const
style
=
StyleSheet
.
create
({
overlay
:
{
overlay
:
{
...
...
src/maps/MultiPoint.js
View file @
675efab5
import
React
,
{
PureComponent
}
from
'react'
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
requireNativeComponent
,
resolveAssetSource
,
ViewPropTypes
}
from
'react-native'
import
{
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
export
default
class
MultiPoint
extends
PureComponent
{
export
default
class
MultiPoint
extends
PureComponent
{
static
propTypes
=
{
static
propTypes
=
{
...
...
src/maps/Polygon.js
View file @
675efab5
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
PixelRatio
,
Platform
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
ColorPropType
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
import
{
LatLng
}
from
'../PropTypes'
export
default
class
Polygon
extends
PureComponent
{
export
default
requireNativeComponent
(
'AMapPolygon'
,
{
static
propTypes
=
{
propTypes
:
{
...
ViewPropTypes
,
...
ViewPropTypes
,
/**
/**
...
@@ -20,30 +19,16 @@ export default class Polygon extends PureComponent {
...
@@ -20,30 +19,16 @@ export default class Polygon extends PureComponent {
/**
/**
* 边线颜色
* 边线颜色
*/
*/
strokeColor
:
PropTypes
.
string
,
strokeColor
:
ColorPropType
,
/**
/**
* 填充颜色
* 填充颜色
*/
*/
fillColor
:
PropTypes
.
string
,
fillColor
:
ColorPropType
,
/**
/**
* 层级
* 层级
*/
*/
zIndex
:
PropTypes
.
number
,
zIndex
:
PropTypes
.
number
,
}
render
()
{
const
props
=
{
...
this
.
props
,
...
Platform
.
select
({
android
:
{
strokeWidth
:
PixelRatio
.
getPixelSizeForLayoutSize
(
this
.
props
.
strokeWidth
),
},
},
}),
})
}
return
<
AMapPolygon
{...
props
}
/
>
}
}
const
AMapPolygon
=
requireNativeComponent
(
'AMapPolygon'
,
Polygon
)
src/maps/Polyline.js
View file @
675efab5
import
React
,
{
PureComponent
}
from
'react'
import
React
,
{
PureComponent
}
from
'react'
import
PropTypes
from
'prop-types'
import
PropTypes
from
'prop-types'
import
{
PixelRatio
,
Platform
,
processColor
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
ColorPropType
,
Platform
,
processColor
,
requireNativeComponent
,
ViewPropTypes
}
from
'react-native'
import
{
LatLng
}
from
'../PropTypes'
import
{
LatLng
}
from
'../PropTypes'
export
default
class
Polyline
extends
PureComponent
{
export
default
class
Polyline
extends
PureComponent
{
...
@@ -20,7 +20,7 @@ export default class Polyline extends PureComponent {
...
@@ -20,7 +20,7 @@ export default class Polyline extends PureComponent {
/**
/**
* 线段颜色
* 线段颜色
*/
*/
color
:
PropTypes
.
string
,
color
:
ColorPropType
,
/**
/**
* 层级
* 层级
...
@@ -30,10 +30,7 @@ export default class Polyline extends PureComponent {
...
@@ -30,10 +30,7 @@ export default class Polyline extends PureComponent {
/**
/**
* 多段颜色
* 多段颜色
*/
*/
colors
:
PropTypes
.
oneOfType
([
colors
:
PropTypes
.
arrayOf
(
ColorPropType
),
PropTypes
.
arrayOf
(
PropTypes
.
number
),
PropTypes
.
arrayOf
(
PropTypes
.
string
),
]),
/**
/**
* 是否使用颜色渐变
* 是否使用颜色渐变
...
@@ -65,7 +62,6 @@ export default class Polyline extends PureComponent {
...
@@ -65,7 +62,6 @@ export default class Polyline extends PureComponent {
...
this
.
props
,
...
this
.
props
,
...
Platform
.
select
({
...
Platform
.
select
({
android
:
{
android
:
{
width
:
PixelRatio
.
getPixelSizeForLayoutSize
(
this
.
props
.
width
),
colors
:
this
.
props
.
colors
.
map
(
processColor
),
colors
:
this
.
props
.
colors
.
map
(
processColor
),
},
},
}),
}),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment