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
3cc70dfd
Commit
3cc70dfd
authored
Jul 13, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简化 Region 结构
parent
764885ba
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
75 deletions
+26
-75
AMapConverter.kt
...d/src/main/java/cn/qiuxiang/react/amap3d/AMapConverter.kt
+0
-35
AMapView.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
+13
-4
AMapViewManager.kt
...src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
+1
-1
MapView.js
components/MapView.js
+2
-2
PropTypes.js
components/PropTypes.js
+4
-11
RCTConvert+AMapView.m
ios/RCTConvert+AMapView.m
+6
-22
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapConverter.kt
deleted
100644 → 0
View file @
764885ba
package
cn.qiuxiang.react.amap3d
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.LatLngBounds
import
com.facebook.react.bridge.ReadableMap
import
android.graphics.Color
/**
* Created by yuekong on 2017/7/4.
*/
class
AMapConverter
{
companion
object
{
fun
LatLng
(
map
:
ReadableMap
):
LatLng
{
return
LatLng
(
map
.
getDouble
(
"latitude"
),
map
.
getDouble
(
"longitude"
))
}
fun
LatLngDelta
(
map
:
ReadableMap
):
LatLng
{
return
LatLng
(
map
.
getDouble
(
"latitudeDelta"
),
map
.
getDouble
(
"longitudeDelta"
))
}
fun
LatLngBounds
(
map
:
ReadableMap
):
LatLngBounds
{
val
center
=
LatLng
(
map
.
getMap
(
"center"
))
val
span
=
LatLngDelta
(
map
.
getMap
(
"span"
))
return
LatLngBounds
(
LatLng
(
center
.
latitude
-
span
.
latitude
,
center
.
longitude
-
span
.
longitude
),
LatLng
(
center
.
latitude
+
span
.
latitude
,
center
.
longitude
+
span
.
longitude
)
)
}
fun
color
(
color
:
Int
,
opacity
:
Float
):
Int
{
return
Color
.
argb
(((
opacity
*
Color
.
alpha
(
color
)).
toInt
()),
Color
.
red
(
color
),
Color
.
green
(
color
),
Color
.
blue
(
color
))
}
}
}
\ No newline at end of file
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
View file @
3cc70dfd
...
...
@@ -6,12 +6,10 @@ import android.view.View
import
com.amap.api.maps.AMap
import
com.amap.api.maps.CameraUpdateFactory
import
com.amap.api.maps.MapView
import
com.amap.api.maps.model.CameraPosition
import
com.amap.api.maps.model.LatLng
import
com.amap.api.maps.model.Marker
import
com.amap.api.maps.model.MyLocationStyle
import
com.amap.api.maps.model.*
import
com.facebook.react.bridge.Arguments
import
com.facebook.react.bridge.ReadableArray
import
com.facebook.react.bridge.ReadableMap
import
com.facebook.react.bridge.WritableMap
import
com.facebook.react.uimanager.ThemedReactContext
import
com.facebook.react.uimanager.events.RCTEventEmitter
...
...
@@ -205,4 +203,15 @@ class AMapView(context: Context) : MapView(context) {
CameraPosition
(
coordinate
,
zoomLevel
,
tilt
,
rotation
))
map
.
animateCamera
(
cameraUpdate
,
duration
.
toLong
(),
animateCallback
)
}
fun
setLimitRegion
(
limitRegion
:
ReadableMap
)
{
val
latitude
=
limitRegion
.
getDouble
(
"latitude"
)
val
longitude
=
limitRegion
.
getDouble
(
"longitude"
)
val
latitudeDelta
=
limitRegion
.
getDouble
(
"latitudeDelta"
)
val
longitudeDelta
=
limitRegion
.
getDouble
(
"longitudeDelta"
)
map
.
setMapStatusLimits
(
LatLngBounds
(
LatLng
(
latitude
-
latitudeDelta
,
longitude
-
longitudeDelta
),
LatLng
(
latitude
+
latitudeDelta
,
longitude
+
longitudeDelta
)
))
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
View file @
3cc70dfd
...
...
@@ -165,7 +165,7 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
@ReactProp
(
name
=
"limitRegion"
)
fun
setLimitRegion
(
view
:
AMapView
,
limitRegion
:
ReadableMap
)
{
view
.
map
.
setMapStatusLimits
(
AMapConverter
.
LatLngBounds
(
limitRegion
)
)
view
.
setLimitRegion
(
limitRegion
)
}
@ReactProp
(
name
=
"tilt"
)
...
...
components/MapView.js
View file @
3cc70dfd
...
...
@@ -97,12 +97,12 @@ class MapView extends Component {
coordinate
:
LatLng
,
/**
*
设置可见地图区域的矩形
*
限制地图只能显示某个矩形区域
*/
limitRegion
:
Region
,
/**
*
设置
倾斜角度,取值范围 [0, 60]
* 倾斜角度,取值范围 [0, 60]
*/
tilt
:
PropTypes
.
number
,
...
...
components/PropTypes.js
View file @
3cc70dfd
...
...
@@ -5,19 +5,12 @@ const LatLng = PropTypes.shape({
longitude
:
PropTypes
.
number
.
isRequired
,
})
const
Span
=
PropTypes
.
shape
({
const
Region
=
PropTypes
.
shape
({
latitude
:
PropTypes
.
number
.
isRequired
,
longitude
:
PropTypes
.
number
.
isRequired
,
latitudeDelta
:
PropTypes
.
number
.
isRequired
,
longitudeDelta
:
PropTypes
.
number
.
isRequired
,
})
const
Region
=
PropTypes
.
shape
({
center
:
LatLng
,
span
:
Span
,
})
export
{
LatLng
,
Span
,
Region
,
}
export
{
LatLng
,
Region
}
ios/RCTConvert+AMapView.m
View file @
3cc70dfd
#import <MAMapKit/MAMapView.h>
#import <MAMapKit/MAGeometry.h>
#import <React/RCTConvert.h>
#import <React/RCTConvert+CoreLocation.h>
#import "Coordinate.h"
...
...
@@ -21,30 +20,15 @@ RCT_ENUM_CONVERTER(MAPinAnnotationColor, (@{
}),
MAPinAnnotationColorRed
,
integerValue
)
+
(
Coordinate
*
)
Coordinate
:
(
id
)
json
{
return
[[
Coordinate
alloc
]
initWithCoordinate
:
[
self
CLLocationCoordinate2D
:
json
]];
}
+
(
MACoordinateSpan
)
MACoordinateSpan
:
(
id
)
json
{
json
=
[
self
NSDictionary
:
json
];
return
(
MACoordinateSpan
){
[
self
CLLocationDegrees
:
json
[
@"latitudeDelta"
]],
[
self
CLLocationDegrees
:
json
[
@"longitudeDelta"
]]
};
return
[[
Coordinate
alloc
]
initWithCoordinate
:[
self
CLLocationCoordinate2D
:
json
]];
}
+
(
MACoordinateRegion
)
MACoordinateRegion
:
(
id
)
json
{
return
(
MACoordinateRegion
){
[
self
CLLocationCoordinate2D
:
json
[
@"center"
]],
[
self
MACoordinateSpan
:
json
[
@"span"
]]
};
}
+
(
MAMapStatus
*
)
MAMapStatus
:
(
id
)
json
{
return
[
MAMapStatus
statusWithCenterCoordinate
:(
json
[
@"centerCoordinate"
]
?
[
self
CLLocationCoordinate2D
:
json
[
@"centerCoordinate"
]]
:
(
CLLocationCoordinate2D
){
-
1
.
0
f
,
-
1
.
0
f
})
zoomLevel
:
json
[
@"zoomLevel"
]
?
[
self
CGFloat
:
json
[
@"zoomLevel"
]]
:
-
1
rotationDegree
:
json
[
@"rotationDegree"
]
?
[
self
CGFloat
:
json
[
@"rotationDegree"
]]
:
-
1
cameraDegree
:
json
[
@"cameraDegree"
]
?
[
self
CGFloat
:
json
[
@"cameraDegree"
]]
:
-
1
screenAnchor
:
json
[
@"screenAnchor"
]
?
[
self
CGPoint
:
json
[
@"screenAnchor"
]]
:
CGPointMake
(
-
1
,
-
1
)];
return
MACoordinateRegionMake
(
[
self
CLLocationCoordinate2D
:
json
],
MACoordinateSpanMake
(
[
self
CLLocationDegrees
:
json
[
@"latitudeDelta"
]],
[
self
CLLocationDegrees
:
json
[
@"longitudeDelta"
]]));
}
RCT_ARRAY_CONVERTER
(
Coordinate
)
...
...
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