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
4c40aece
Commit
4c40aece
authored
Jun 14, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 iOS marker 事件接口
parent
2532d141
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
36 deletions
+64
-36
AMapMarker.h
ios/AMapMarker.h
+10
-1
AMapMarker.m
ios/AMapMarker.m
+2
-0
AMapMarkerManager.m
ios/AMapMarkerManager.m
+6
-0
AMapView.h
ios/AMapView.h
+7
-4
AMapViewManager.m
ios/AMapViewManager.m
+39
-31
No files found.
ios/AMapMarker.h
View file @
4c40aece
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#import <MAMapKit/MAMapKit.h>
#import <React/RCTComponent.h>
#pragma ide diagnostic ignored "OCUnusedPropertyInspection"
@class
AMapView
;
@class
AMapView
;
...
@@ -8,8 +11,14 @@
...
@@ -8,8 +11,14 @@
@property
(
nonatomic
,
assign
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
assign
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
copy
)
NSString
*
title
;
@property
(
nonatomic
,
copy
)
NSString
*
title
;
@property
(
nonatomic
,
copy
)
NSString
*
subtitle
;
@property
(
nonatomic
,
copy
)
NSString
*
subtitle
;
@property
(
nonatomic
,
assign
)
BOOL
_active
;
@property
(
nonatomic
,
strong
)
AMapView
*
mapView
;
@property
(
nonatomic
,
strong
)
AMapView
*
mapView
;
@property
(
nonatomic
,
assign
)
BOOL
_active
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onInfoWindowPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onDragStart
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onDrag
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onDragEnd
;
-
(
MAAnnotationView
*
)
getAnnotationView
;
-
(
MAAnnotationView
*
)
getAnnotationView
;
-
(
BOOL
)
active
;
-
(
BOOL
)
active
;
...
...
ios/AMapMarker.m
View file @
4c40aece
#import "AMapMarker.h"
#import "AMapMarker.h"
#import "AMapView.h"
#import "AMapView.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation
AMapMarker
{
@implementation
AMapMarker
{
MAAnnotationView
*
_pinView
;
MAAnnotationView
*
_pinView
;
}
}
...
...
ios/AMapMarkerManager.m
View file @
4c40aece
...
@@ -26,4 +26,10 @@ RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
...
@@ -26,4 +26,10 @@ RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
RCT_EXPORT_VIEW_PROPERTY
(
infoWindowEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
infoWindowEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
zIndex
,
NSInteger
)
RCT_EXPORT_VIEW_PROPERTY
(
zIndex
,
NSInteger
)
RCT_EXPORT_VIEW_PROPERTY
(
onPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onInfoWindowPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onDragStart
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onDrag
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onDragEnd
,
RCTBubblingEventBlock
)
@end
@end
ios/AMapView.h
View file @
4c40aece
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
#import <React/RCTComponent.h>
#import <React/RCTComponent.h>
@interface
AMapView
:
MAMapView
@interface
AMapView
:
MAMapView
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onReady
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLocation
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onReady
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLocation
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLongPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onPress
;
@property
(
nonatomic
,
copy
)
RCTBubblingEventBlock
onLongPress
;
@end
@end
\ No newline at end of file
ios/AMapViewManager.m
View file @
4c40aece
...
@@ -23,85 +23,62 @@ RCT_EXPORT_MODULE()
...
@@ -23,85 +23,62 @@ RCT_EXPORT_MODULE()
}
}
RCT_EXPORT_VIEW_PROPERTY
(
locationEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
locationEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsCompass
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsCompass
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsScale
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsScale
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsIndoorMap
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsIndoorMap
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsLabels
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsLabels
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsTraffic
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsTraffic
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsBuildings
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
showsBuildings
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
zoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
zoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
maxZoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
maxZoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
minZoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
minZoomLevel
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
zoomEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
zoomEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
scrollEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
scrollEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
rotateEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
rotateEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
tiltEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
tiltEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
mapType
,
MAMapType
)
RCT_EXPORT_VIEW_PROPERTY
(
mapType
,
MAMapType
)
RCT_EXPORT_VIEW_PROPERTY
(
coordinate
,
CLLocationCoordinate2D
)
RCT_EXPORT_VIEW_PROPERTY
(
coordinate
,
CLLocationCoordinate2D
)
RCT_EXPORT_VIEW_PROPERTY
(
tilt
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
tilt
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
onReady
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onReady
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLongPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLongPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLocation
,
RCTBubblingEventBlock
)
RCT_EXPORT_VIEW_PROPERTY
(
onLocation
,
RCTBubblingEventBlock
)
#pragma mark MAMapViewDelegate
#pragma mark MAMapViewDelegate
-
(
void
)
mapInitComplete
:
(
AMapView
*
)
mapView
{
-
(
void
)
mapInitComplete
:
(
AMapView
*
)
mapView
{
if
(
!
mapView
.
onReady
)
{
if
(
mapView
.
onReady
)
{
return
;
}
mapView
.
onReady
(@{});
mapView
.
onReady
(@{});
}
}
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didSingleTappedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didSingleTappedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
if
(
!
mapView
.
onPress
)
{
if
(
mapView
.
onPress
)
{
return
;
}
mapView
.
onPress
(@{
mapView
.
onPress
(@{
@"latitude"
:
@
(
coordinate
.
latitude
),
@"latitude"
:
@
(
coordinate
.
latitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
});
});
}
}
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didLongPressedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didLongPressedAtCoordinate
:
(
CLLocationCoordinate2D
)
coordinate
{
if
(
!
mapView
.
onLongPress
)
{
if
(
mapView
.
onLongPress
)
{
return
;
}
mapView
.
onLongPress
(@{
mapView
.
onLongPress
(@{
@"latitude"
:
@
(
coordinate
.
latitude
),
@"latitude"
:
@
(
coordinate
.
latitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
@"longitude"
:
@
(
coordinate
.
longitude
),
});
});
}
}
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didUpdateUserLocation
:
(
MAUserLocation
*
)
userLocation
updatingLocation
:
(
BOOL
)
updatingLocation
{
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didUpdateUserLocation
:
(
MAUserLocation
*
)
userLocation
updatingLocation
:
(
BOOL
)
updatingLocation
{
if
(
!
mapView
.
onLocation
)
{
if
(
mapView
.
onLocation
)
{
return
;
}
mapView
.
onLocation
(@{
mapView
.
onLocation
(@{
@"latitude"
:
@
(
userLocation
.
coordinate
.
latitude
),
@"latitude"
:
@
(
userLocation
.
coordinate
.
latitude
),
@"longitude"
:
@
(
userLocation
.
coordinate
.
longitude
),
@"longitude"
:
@
(
userLocation
.
coordinate
.
longitude
),
@"accuracy"
:
@
((
userLocation
.
location
.
horizontalAccuracy
+
userLocation
.
location
.
verticalAccuracy
)
/
2
),
@"accuracy"
:
@
((
userLocation
.
location
.
horizontalAccuracy
+
userLocation
.
location
.
verticalAccuracy
)
/
2
),
});
});
}
}
}
-
(
MAAnnotationView
*
)
mapView
:
(
MAMapView
*
)
mapView
viewForAnnotation
:
(
AMapMarker
*
)
marker
{
-
(
MAAnnotationView
*
)
mapView
:
(
MAMapView
*
)
mapView
viewForAnnotation
:
(
AMapMarker
*
)
marker
{
...
@@ -111,4 +88,35 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
...
@@ -111,4 +88,35 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
return
[
marker
getAnnotationView
];
return
[
marker
getAnnotationView
];
}
}
-
(
void
)
mapView
:
(
MAMapView
*
)
mapView
didSelectAnnotationView
:
(
MAAnnotationView
*
)
view
{
AMapMarker
*
marker
=
(
AMapMarker
*
)
view
.
annotation
;
if
(
marker
.
onPress
)
{
marker
.
onPress
(@{});
}
}
-
(
void
)
mapView
:
(
MAMapView
*
)
mapView
didAnnotationViewCalloutTapped
:
(
MAAnnotationView
*
)
view
{
AMapMarker
*
marker
=
(
AMapMarker
*
)
view
.
annotation
;
if
(
marker
.
onInfoWindowPress
)
{
marker
.
onInfoWindowPress
(@{});
}
}
-
(
void
)
mapView
:
(
MAMapView
*
)
mapView
annotationView
:
(
MAAnnotationView
*
)
view
didChangeDragState
:
(
MAAnnotationViewDragState
)
newState
fromOldState
:
(
MAAnnotationViewDragState
)
oldState
{
AMapMarker
*
marker
=
(
AMapMarker
*
)
view
.
annotation
;
if
(
newState
==
MAAnnotationViewDragStateStarting
&&
marker
.
onDragStart
)
{
marker
.
onDragStart
(@{});
}
if
(
newState
==
MAAnnotationViewDragStateDragging
&&
marker
.
onDrag
)
{
marker
.
onDrag
(@{});
}
if
(
newState
==
MAAnnotationViewDragStateEnding
&&
marker
.
onDragEnd
)
{
marker
.
onDragEnd
(@{
@"latitude"
:
@
(
marker
.
coordinate
.
latitude
),
@"longitude"
:
@
(
marker
.
coordinate
.
longitude
),
});
}
}
@end
@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