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
2532d141
Commit
2532d141
authored
Jun 14, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 iOS 基本 marker 添加
parent
dc63c879
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
7 deletions
+113
-7
AMapMarker.h
ios/AMapMarker.h
+18
-0
AMapMarker.m
ios/AMapMarker.m
+39
-0
AMapMarkerManager.m
ios/AMapMarkerManager.m
+29
-0
AMapView.m
ios/AMapView.m
+14
-0
AMapViewManager.m
ios/AMapViewManager.m
+13
-7
No files found.
ios/AMapMarker.h
0 → 100644
View file @
2532d141
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
@class
AMapView
;
@interface
AMapMarker
:
MAAnnotationView
<
MAAnnotation
>
@property
(
nonatomic
,
assign
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
copy
)
NSString
*
title
;
@property
(
nonatomic
,
copy
)
NSString
*
subtitle
;
@property
(
nonatomic
,
assign
)
BOOL
_active
;
@property
(
nonatomic
,
strong
)
AMapView
*
mapView
;
-
(
MAAnnotationView
*
)
getAnnotationView
;
-
(
BOOL
)
active
;
@end
\ No newline at end of file
ios/AMapMarker.m
0 → 100644
View file @
2532d141
#import "AMapMarker.h"
#import "AMapView.h"
@implementation
AMapMarker
{
MAAnnotationView
*
_pinView
;
}
-
(
void
)
setActive
:
(
BOOL
)
active
{
self
.
_active
=
active
;
if
(
active
)
{
[
self
.
mapView
selectAnnotation
:
self
animated
:
YES
];
}
}
-
(
void
)
setDescription
:
(
NSString
*
)
description
{
self
.
subtitle
=
description
;
}
-
(
void
)
setInfoWindowEnabled
:
(
BOOL
)
enabled
{
self
.
canShowCallout
=
enabled
;
}
-
(
MAAnnotationView
*
)
getAnnotationView
{
if
(
_pinView
==
nil
)
{
_pinView
=
[[
MAPinAnnotationView
alloc
]
initWithAnnotation
:
self
reuseIdentifier
:
nil
];
_pinView
.
annotation
=
self
;
}
_pinView
.
zIndex
=
self
.
zIndex
;
_pinView
.
draggable
=
self
.
draggable
;
_pinView
.
canShowCallout
=
self
.
canShowCallout
;
return
_pinView
;
}
-
(
BOOL
)
active
{
return
self
.
_active
;
}
@end
\ No newline at end of file
ios/AMapMarkerManager.m
0 → 100644
View file @
2532d141
#import <MAMapKit/MAMapView.h>
#import <React/RCTViewManager.h>
#import "AMapMarker.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapMarkerManager
:
RCTViewManager
<
MAMapViewDelegate
>
@end
@implementation
AMapMarkerManager
{
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
AMapMarker
*
marker
=
[
AMapMarker
new
];
marker
.
canShowCallout
=
YES
;
return
marker
;
}
RCT_EXPORT_VIEW_PROPERTY
(
coordinate
,
CLLocationCoordinate2D
)
RCT_EXPORT_VIEW_PROPERTY
(
title
,
NSString
)
RCT_EXPORT_VIEW_PROPERTY
(
description
,
NSString
)
RCT_EXPORT_VIEW_PROPERTY
(
active
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
draggable
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
infoWindowEnabled
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
zIndex
,
NSInteger
)
@end
ios/AMapView.m
View file @
2532d141
#import "AMapView.h"
#import "AMapMarker.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
...
...
@@ -25,4 +26,17 @@
super
.
cameraDegree
=
degree
;
}
-
(
void
)
insertReactSubview
:
(
id
<
RCTComponent
>
)
subview
atIndex
:
(
NSInteger
)
atIndex
{
if
([
subview
isKindOfClass
:[
AMapMarker
class
]])
{
((
AMapMarker
*
)
subview
).
mapView
=
self
;
[
self
addAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
}
}
-
(
void
)
removeReactSubview
:
(
id
<
RCTComponent
>
)
subview
{
if
([
subview
isKindOfClass
:[
AMapMarker
class
]])
{
[
self
removeAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
}
}
@end
ios/AMapViewManager.m
View file @
2532d141
#import <MAMapKit/MAMapKit.h>
#import <React/RCTViewManager.h>
#import "AMapView.h"
#import "AMapMarker.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "-Woverriding-method-mismatch"
...
...
@@ -9,17 +10,16 @@
@end
@implementation
AMapViewManager
{
AMapView
*
_mapView
;
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
_mapView
=
[[
AMapView
alloc
]
init
];
_
mapView
.
centerCoordinate
=
CLLocationCoordinate2DMake
(
39
.
9042
,
116
.
4074
);
_
mapView
.
zoomLevel
=
10
;
_
mapView
.
delegate
=
self
;
return
_
mapView
;
AMapView
*
mapView
=
[
AMapView
new
];
mapView
.
centerCoordinate
=
CLLocationCoordinate2DMake
(
39
.
9042
,
116
.
4074
);
mapView
.
zoomLevel
=
10
;
mapView
.
delegate
=
self
;
return
mapView
;
}
RCT_EXPORT_VIEW_PROPERTY
(
locationEnabled
,
BOOL
)
...
...
@@ -94,7 +94,6 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
}
-
(
void
)
mapView
:
(
AMapView
*
)
mapView
didUpdateUserLocation
:
(
MAUserLocation
*
)
userLocation
updatingLocation
:
(
BOOL
)
updatingLocation
{
NSLog
(
@"location"
);
if
(
!
mapView
.
onLocation
)
{
return
;
}
...
...
@@ -105,4 +104,11 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
});
}
-
(
MAAnnotationView
*
)
mapView
:
(
MAMapView
*
)
mapView
viewForAnnotation
:
(
AMapMarker
*
)
marker
{
if
(
marker
.
active
)
{
[
mapView
selectAnnotation
:
marker
animated
:
YES
];
}
return
[
marker
getAnnotationView
];
}
@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