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
f4a53798
Commit
f4a53798
authored
Jun 13, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 iOS 基本事件接口
parent
20d84519
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
11 deletions
+76
-11
README.md
README.md
+3
-3
AMapView.h
ios/AMapView.h
+6
-0
AMapView.m
ios/AMapView.m
+8
-2
AMapViewManager.m
ios/AMapViewManager.m
+59
-6
No files found.
README.md
View file @
f4a53798
...
...
@@ -149,9 +149,9 @@ import MapView from 'react-native-amap3d'
-
[
x
]
室内地图
-
[
]
内置地图控件(指南针和比例尺通过内置接口提供支持,定位按钮、缩放按钮需要自行实现)
-
[
x
]
手势交互(平移、缩放、旋转、倾斜)
-
[
x
]
中心坐标、缩放级别、倾斜度
🚀
-
[
]
地图事件(onPress、onLongPress、onLocation)
-
[
]
地图标记(Marker)
-
[
x
]
中心坐标、缩放级别、倾斜度
-
[
x
]
地图事件(onPress、onLongPress、onLocation)
-
[
]
地图标记(Marker)
🚀
-
[
]
基本属性及事件
-
[
]
自定义信息窗体
-
[
]
自定义图标
...
...
ios/AMapView.h
View file @
f4a53798
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#import <RCTComponent.h>
@interface
AMapView
:
MAMapView
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onReady
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLocation
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLongPress
;
@end
\ No newline at end of file
ios/AMapView.m
View file @
f4a53798
#import "AMapView.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation
AMapView
{
}
-
(
void
)
setShowsTraffic
:
(
BOOL
)
shows
{
[
super
setShowTraffic
:
shows
]
;
super
.
showTraffic
=
shows
;
}
-
(
void
)
setTiltEnabled
:
(
BOOL
)
enabled
{
[
super
setRotateCameraEnabled
:
enabled
];
super
.
rotateCameraEnabled
=
enabled
;
}
-
(
void
)
setLocationEnabled
:
(
BOOL
)
enabled
{
super
.
showsUserLocation
=
enabled
;
}
-
(
void
)
setCoordinate
:
(
CLLocationCoordinate2D
)
json
{
...
...
ios/AMapViewManager.m
View file @
f4a53798
...
...
@@ -3,22 +3,26 @@
#import "AMapView.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapViewManager
:
RCTViewManager
@interface
AMapViewManager
:
RCTViewManager
<
MAMapViewDelegate
>
@end
@implementation
AMapViewManager
{
AMapView
*
mapView
;
AMapView
*
_
mapView
;
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
mapView
=
[[
AMapView
alloc
]
init
];
mapView
.
centerCoordinate
=
CLLocationCoordinate2DMake
(
39
.
9042
,
116
.
4074
);
mapView
.
zoomLevel
=
10
;
return
mapView
;
_mapView
=
[[
AMapView
alloc
]
init
];
_mapView
.
centerCoordinate
=
CLLocationCoordinate2DMake
(
39
.
9042
,
116
.
4074
);
_mapView
.
zoomLevel
=
10
;
_mapView
.
delegate
=
self
;
return
_mapView
;
}
RCT_EXPORT_VIEW_PROPERTY
(
locationEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsCompass
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsScale
,
BOOL
)
...
...
@@ -51,4 +55,53 @@ RCT_EXPORT_VIEW_PROPERTY(coordinate, CLLocationCoordinate2D)
RCT_EXPORT_VIEW_PROPERTY
(
tilt
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
onReady
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLongPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLocation
,
RCTBubblingEventBlock
)
#pragma mark MAMapViewDelegate
-
(
void
)
mapInitComplete
:
(
AMapView
*
)
mapView
{
if
(
!
mapView
.
onReady
)
{
return
;
}
mapView
.
onReady
(@{});
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didSingleTappedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
if
(
!
mapView
.
onPress
)
{
return
;
}
mapView
.
onPress
(@{
@"latitude"
:
@
(
coordinate
.
latitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
});
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didLongPressedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
if
(
!
mapView
.
onLongPress
)
{
return
;
}
mapView
.
onLongPress
(@{
@"latitude"
:
@
(
coordinate
.
latitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
});
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didUpdateUserLocation
:
(
MAUserLocation
*
)
userLocation
updatingLocation
:
(
BOOL
)
updatingLocation
{
NSLog
(
@"location"
);
if
(
!
mapView
.
onLocation
)
{
return
;
}
mapView
.
onLocation
(@{
@"latitude"
:
@
(
userLocation
.
coordinate
.
latitude
),
@"longitude"
:
@
(
userLocation
.
coordinate
.
longitude
),
@"accuracy"
:
@
((
userLocation
.
location
.
horizontalAccuracy
+
userLocation
.
location
.
verticalAccuracy
)
/
2
),
});
}
@end
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