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
3d1c59fa
Commit
3d1c59fa
authored
Nov 02, 2018
by
放牛的园子
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wangqb_dev' into 'master'
已经完成ios版本的相关动画移动,路径贴图功能 See merge request
!2
parents
f5ae8752
b3bb3058
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
345 additions
and
5 deletions
+345
-5
AMapMarker.m
lib/ios/AMap3D/maps/AMapMarker.m
+7
-3
AMapPathPolyline.h
lib/ios/AMap3D/maps/AMapPathPolyline.h
+11
-0
AMapPathPolyline.m
lib/ios/AMap3D/maps/AMapPathPolyline.m
+78
-0
AMapPathPolylineManager.m
lib/ios/AMap3D/maps/AMapPathPolylineManager.m
+25
-0
AMapSmoothMoveMarker.h
lib/ios/AMap3D/maps/AMapSmoothMoveMarker.h
+18
-0
AMapSmoothMoveMarker.m
lib/ios/AMap3D/maps/AMapSmoothMoveMarker.m
+139
-0
AMapSmoothMoveMarkerManager.m
lib/ios/AMap3D/maps/AMapSmoothMoveMarkerManager.m
+39
-0
AMapView.h
lib/ios/AMap3D/maps/AMapView.h
+3
-1
AMapView.m
lib/ios/AMap3D/maps/AMapView.m
+19
-0
AMapViewManager.m
lib/ios/AMap3D/maps/AMapViewManager.m
+5
-0
react-native-amap3d.podspec
lib/ios/react-native-amap3d.podspec
+1
-1
No files found.
lib/ios/AMap3D/maps/AMapMarker.m
View file @
3d1c59fa
...
...
@@ -85,6 +85,10 @@
});
}
-
(
void
)
layoutSubviews
{
NSLog
(
@"CustomSubview layoutSubviews"
);
}
-
(
void
)
setInfoWindowDisabled
:
(
BOOL
)
disabled
{
_canShowCallout
=
!
disabled
;
_annotationView
.
canShowCallout
=
!
disabled
;
...
...
@@ -130,12 +134,12 @@
_annotationView
.
canShowCallout
=
_canShowCallout
;
_annotationView
.
draggable
=
_draggable
;
_annotationView
.
customCalloutView
=
_calloutView
;
_annotationView
.
centerOffset
=
_centerOffset
;
//设置中心点
CGPoint
point
=
CGPointMake
(
0
,
-
_customView
.
bounds
.
size
.
height
/
2
);
_annotationView
.
centerOffset
=
point
;
if
(
_zIndex
)
{
_annotationView
.
zIndex
=
_zIndex
;
}
if
(
_image
!=
nil
)
{
_annotationView
.
image
=
_image
;
}
...
...
lib/ios/AMap3D/maps/AMapPathPolyline.h
0 → 100644
View file @
3d1c59fa
#import <MAMapKit/MAMapKit.h>
#import "AMapOverlay.h"
#pragma ide diagnostic ignored "OCUnusedPropertyInspection"
@interface
AMapPathPolyline
:
AMapOverlay
@property
(
nonatomic
,
readonly
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
readonly
)
MAMapRect
boundingMapRect
;
@end
lib/ios/AMap3D/maps/AMapPathPolyline.m
0 → 100644
View file @
3d1c59fa
#import "AMapPathPolyline.h"
#import "Coordinate.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation
AMapPathPolyline
{
MAPolyline
*
_polyline
;
MAPolylineRenderer
*
_renderer
;
UIImage
*
_image
;
CGFloat
_width
;
UIColor
*
_color
;
NSArray
*
_colors
;
BOOL
_dashed
;
BOOL
_gradient
;
}
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
_polyline
=
[
MAPolyline
polylineWithCoordinates
:
nil
count
:
0
];
}
return
self
;
}
-
(
void
)
setCoordinates
:
(
NSArray
<
Coordinate
*>
*
)
coordinates
{
CLLocationCoordinate2D
coords
[
coordinates
.
count
];
for
(
NSUInteger
i
=
0
;
i
<
coordinates
.
count
;
i
++
)
{
coords
[
i
]
=
coordinates
[
i
].
coordinate
;
}
[
_polyline
setPolylineWithCoordinates
:
coords
count
:
coordinates
.
count
];
}
-
(
void
)
setWidth
:
(
CGFloat
)
width
{
_width
=
width
;
_renderer
.
lineWidth
=
width
;
}
-
(
void
)
setColor
:
(
UIColor
*
)
color
{
_color
=
color
;
_renderer
.
strokeColor
=
color
;
}
-
(
CLLocationCoordinate2D
)
coordinate
{
return
_polyline
.
coordinate
;
}
-
(
MAMapRect
)
boundingMapRect
{
return
_polyline
.
boundingMapRect
;
}
-
(
void
)
setImage
:
(
NSString
*
)
name
{
_image
=
[
UIImage
imageNamed
:
name
];
//UIImage *temp = [UIImage imageNamed:@"path8"];
//_renderer.strokeTextureImages = _images;
//[_polyline setDrawStyleIndexes:@[@(1),@(2)]];
}
-
(
MAOverlayRenderer
*
)
renderer
{
if
(
_color
==
nil
)
{
_color
=
UIColor
.
blackColor
;
}
if
(
_renderer
==
nil
)
{
_renderer
=
[[
MAPolylineRenderer
alloc
]
initWithPolyline
:
_polyline
];
_renderer
.
lineWidth
=
_width
;
_renderer
.
strokeColor
=
_color
;
//[_renderer loadTexture:[UIImage imageNamed:@"path8"]];
if
(
_image
!=
nil
){
[
_renderer
loadStrokeTextureImage
:
_image
];
}
//_renderer.strokeTextureImages = _images;
}
return
_renderer
;
}
@end
lib/ios/AMap3D/maps/AMapPathPolylineManager.m
0 → 100644
View file @
3d1c59fa
#import <MAMapKit/MAMapView.h>
#import <React/RCTViewManager.h>
#import "AMapPathPolyline.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapPathPolylineManager
:
RCTViewManager
@end
@implementation
AMapPathPolylineManager
{
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
return
[
AMapPathPolyline
new
];
}
RCT_EXPORT_VIEW_PROPERTY
(
coordinates
,
CoordinateArray
)
RCT_EXPORT_VIEW_PROPERTY
(
width
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
dashed
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
gradient
,
BOOL
)
RCT_EXPORT_VIEW_PROPERTY
(
image
,
NSString
)
@end
lib/ios/AMap3D/maps/AMapSmoothMoveMarker.h
0 → 100644
View file @
3d1c59fa
#import "AMapView.h"
#import "AMapCallout.h"
@interface
AMapSmoothMoveMarker
:
UIView
@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
*
)
annotationView
;
-
(
MAAnimatedAnnotation
*
)
annotation
;
-
(
void
)
setActive
:(
BOOL
)
active
;
-
(
void
)
setMapView
:(
AMapView
*
)
mapView
;
-
(
void
)
lockToScreen
:(
int
)
x
y
:(
int
)
y
;
@end
lib/ios/AMap3D/maps/AMapSmoothMoveMarker.m
0 → 100644
View file @
3d1c59fa
#import <React/UIView+React.h>
#import "AMapSmoothMoveMarker.h"
#import "Coordinate.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
#pragma clang diagnostic ignored "-Woverriding-method-mismatch"
@implementation
AMapSmoothMoveMarker
{
MAAnimatedAnnotation
*
_annotation
;
//贴图标注
MAAnnotationView
*
_annotationView
;
//标注视图
MACustomCalloutView
*
_calloutView
;
//气泡视图
NSMutableArray
<
Coordinate
*>
*
_coordinates
;
//
UIView
*
_customView
;
__weak
AMapView
*
_mapView
;
MAPinAnnotationColor
_pinColor
;
UIImage
*
_image
;
CGPoint
_centerOffset
;
BOOL
_draggable
;
BOOL
_active
;
BOOL
_canShowCallout
;
//是否显示气泡
BOOL
_enabled
;
NSInteger
_zIndex
;
NSInteger
_duration
;
//动画时间
}
-
(
instancetype
)
init
{
_annotation
=
[
MAAnimatedAnnotation
new
];
_coordinates
=
[[
NSMutableArray
alloc
]
init
];
_enabled
=
YES
;
_canShowCallout
=
YES
;
self
=
[
super
init
];
return
self
;
}
-
(
void
)
setDuration
:
(
NSInteger
)
duration
{
_duration
=
duration
;
}
-
(
void
)
setImage
:
(
NSString
*
)
name
{
_image
=
[
UIImage
imageNamed
:
name
];
if
(
_image
!=
nil
)
{
_annotationView
.
image
=
_image
;
}
}
-
(
void
)
setCoordinates
:
(
NSArray
<
Coordinate
*>
*
)
coordinates
{
[
_coordinates
removeAllObjects
];
[
_coordinates
addObjectsFromArray
:
coordinates
];
CLLocationCoordinate2D
coords
[
coordinates
.
count
];
for
(
NSUInteger
i
=
0
;
i
<
coordinates
.
count
;
i
++
)
{
coords
[
i
]
=
coordinates
[
i
].
coordinate
;
}
_annotation
.
coordinate
=
coords
[
0
];
_annotation
.
title
=
@"I can fly!"
;
if
(
_annotationView
!=
nil
)
{
[
_annotation
addMoveAnimationWithKeyCoordinates
:
coords
count
:
coordinates
.
count
-
1
withDuration
:
_duration
withName
:
nil
completeCallback
:^
(
BOOL
isFinished
)
{
}];
}
}
-
(
void
)
setActive
:
(
BOOL
)
active
{
_active
=
active
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
active
)
{
[
_mapView
selectAnnotation
:
_annotation
animated
:
YES
];
}
else
{
[
_mapView
deselectAnnotation
:
_annotation
animated
:
YES
];
}
});
}
-
(
MAAnimatedAnnotation
*
)
annotation
{
return
_annotation
;
}
-
(
void
)
setMapView
:
(
AMapView
*
)
mapView
{
_mapView
=
mapView
;
}
-
(
void
)
_handleTap
:
(
UITapGestureRecognizer
*
)
recognizer
{
[
_mapView
selectAnnotation
:
_annotation
animated
:
YES
];
}
-
(
MAAnnotationView
*
)
annotationView
{
if
(
_annotationView
==
nil
)
{
if
(
_customView
)
{
_customView
.
hidden
=
NO
;
_annotationView
=
[[
MAAnnotationView
alloc
]
initWithAnnotation
:
_annotation
reuseIdentifier
:
nil
];
_annotationView
.
bounds
=
_customView
.
bounds
;
[
_annotationView
addSubview
:
_customView
];
[
_annotationView
addGestureRecognizer
:[
[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
_handleTap
:)]];
}
else
{
_annotationView
=
[[
MAPinAnnotationView
alloc
]
initWithAnnotation
:
_annotation
reuseIdentifier
:
nil
];
((
MAPinAnnotationView
*
)
_annotationView
).
pinColor
=
_pinColor
;
}
_annotationView
.
enabled
=
_enabled
;
_annotationView
.
canShowCallout
=
_canShowCallout
;
_annotationView
.
draggable
=
_draggable
;
_annotationView
.
customCalloutView
=
_calloutView
;
_annotationView
.
centerOffset
=
_centerOffset
;
if
(
_zIndex
)
{
_annotationView
.
zIndex
=
_zIndex
;
}
if
(
_image
!=
nil
)
{
_annotationView
.
image
=
_image
;
}
CLLocationCoordinate2D
coords
[
_coordinates
.
count
];
for
(
NSUInteger
i
=
0
;
i
<
_coordinates
.
count
;
i
++
)
{
coords
[
i
]
=
_coordinates
[
i
].
coordinate
;
}
[
_annotation
addMoveAnimationWithKeyCoordinates
:
coords
count
:
_coordinates
.
count
-
1
withDuration
:
_duration
withName
:
nil
completeCallback
:^
(
BOOL
isFinished
)
{
}];
[
self
setActive
:
_active
];
}
return
_annotationView
;
}
-
(
void
)
didAddSubview
:
(
UIView
*
)
subview
{
if
([
subview
isKindOfClass
:[
AMapCallout
class
]])
{
_calloutView
=
[[
MACustomCalloutView
alloc
]
initWithCustomView
:
subview
];
_annotationView
.
customCalloutView
=
_calloutView
;
}
else
{
_customView
=
subview
;
_customView
.
hidden
=
YES
;
}
}
-
(
void
)
lockToScreen
:
(
int
)
x
y
:
(
int
)
y
{
_annotation
.
lockedToScreen
=
YES
;
_annotation
.
lockedScreenPoint
=
CGPointMake
(
x
,
y
);
}
@end
lib/ios/AMap3D/maps/AMapSmoothMoveMarkerManager.m
0 → 100644
View file @
3d1c59fa
#import <React/RCTUIManager.h>
#import "AMapSmoothMoveMarker.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapSmoothMoveMarkerManager
:
RCTViewManager
@end
@implementation
AMapSmoothMoveMarkerManager
{
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
return
[
AMapSmoothMoveMarker
new
];
}
RCT_EXPORT_VIEW_PROPERTY
(
coordinates
,
CoordinateArray
)
RCT_EXPORT_VIEW_PROPERTY
(
duration
,
NSInteger
)
RCT_EXPORT_VIEW_PROPERTY
(
image
,
NSString
)
RCT_EXPORT_VIEW_PROPERTY
(
onPress
,
RCTBubblingEventBlock
)
RCT_EXPORT_METHOD
(
lockToScreen
:
(
nonnull
NSNumber
*
)
reactTag
x
:
(
int
)
x
y
:
(
int
)
y
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
__unused
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
AMapSmoothMoveMarker
*
marker
=
(
AMapSmoothMoveMarker
*
)
viewRegistry
[
reactTag
];
[
marker
lockToScreen
:
x
y
:
y
];
}];
}
RCT_EXPORT_METHOD
(
active
:
(
nonnull
NSNumber
*
)
reactTag
)
{
[
self
.
bridge
.
uiManager
addUIBlock
:
^
(
__unused
RCTUIManager
*
uiManager
,
NSDictionary
<
NSNumber
*
,
UIView
*>
*
viewRegistry
)
{
AMapSmoothMoveMarker
*
marker
=
(
AMapSmoothMoveMarker
*
)
viewRegistry
[
reactTag
];
marker
.
active
=
YES
;
}];
}
@end
lib/ios/AMap3D/maps/AMapView.h
View file @
3d1c59fa
#import <MAMapKit/MAMapKit.h>
@class
AMapMarker
;
@class
AMapSmoothMoveMarker
;
@interface
AMapView
:
MAMapView
...
...
@@ -14,5 +15,5 @@
@property
(
nonatomic
)
MACoordinateRegion
initialRegion
;
-
(
AMapMarker
*
)
getMarker
:(
id
<
MAAnnotation
>
)
annotation
;
-
(
AMapSmoothMoveMarker
*
)
getSmoothMarker
:(
id
<
MAAnnotation
>
)
annotation
;
@end
\ No newline at end of file
lib/ios/AMap3D/maps/AMapView.m
View file @
3d1c59fa
#import <React/UIView+React.h>
#import "AMapView.h"
#import "AMapMarker.h"
#import "AMapSmoothMoveMarker.h"
#import "AMapPolyline.h"
#import "LocationStyle.h"
...
...
@@ -8,11 +9,13 @@
@implementation
AMapView
{
NSMutableDictionary
*
_markers
;
NSMutableDictionary
*
_smoothmarkers
;
MAUserLocationRepresentation
*
_locationStyle
;
}
-
(
instancetype
)
init
{
_markers
=
[
NSMutableDictionary
new
];
_smoothmarkers
=
[
NSMutableDictionary
new
];
self
=
[
super
init
];
return
self
;
}
...
...
@@ -74,6 +77,14 @@
[
self
addAnnotation
:
marker
.
annotation
];
});
}
if
([
subview
isKindOfClass
:[
AMapSmoothMoveMarker
class
]]){
AMapSmoothMoveMarker
*
smoothmarker
=
(
AMapSmoothMoveMarker
*
)
subview
;
smoothmarker
.
mapView
=
self
;
_smoothmarkers
[[
@
(
smoothmarker
.
annotation
.
hash
)
stringValue
]]
=
smoothmarker
;
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
self
addAnnotation
:
smoothmarker
.
annotation
];
});
}
if
([
subview
isKindOfClass
:[
AMapOverlay
class
]])
{
[
self
addOverlay
:(
id
<
MAOverlay
>
)
subview
];
}
...
...
@@ -85,6 +96,10 @@
AMapMarker
*
marker
=
(
AMapMarker
*
)
subview
;
[
self
removeAnnotation
:
marker
.
annotation
];
}
if
([
subview
isKindOfClass
:[
AMapSmoothMoveMarker
class
]])
{
AMapSmoothMoveMarker
*
smoothmarker
=
(
AMapSmoothMoveMarker
*
)
subview
;
[
self
removeAnnotation
:
smoothmarker
.
annotation
];
}
if
([
subview
isKindOfClass
:[
AMapOverlay
class
]])
{
[
self
removeOverlay
:(
id
<
MAOverlay
>
)
subview
];
}
...
...
@@ -94,4 +109,8 @@
return
_markers
[[
@
(
annotation
.
hash
)
stringValue
]];
}
-
(
AMapSmoothMoveMarker
*
)
getSmoothMarker
:
(
id
<
MAAnnotation
>
)
annotation
{
return
_smoothmarkers
[[
@
(
annotation
.
hash
)
stringValue
]];
}
@end
lib/ios/AMap3D/maps/AMapViewManager.m
View file @
3d1c59fa
...
...
@@ -2,6 +2,7 @@
#import "AMapView.h"
#import "AMapMarker.h"
#import "AMapOverlay.h"
#import "AMapSmoothMoveMarker.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "-Woverriding-method-mismatch"
...
...
@@ -105,6 +106,10 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)
}
-
(
MAAnnotationView
*
)
mapView
:
(
AMapView
*
)
mapView
viewForAnnotation
:
(
id
<
MAAnnotation
>
)
annotation
{
if
([
annotation
isKindOfClass
:[
MAAnimatedAnnotation
class
]])
{
AMapSmoothMoveMarker
*
marker
=
[
mapView
getSmoothMarker
:
annotation
];
return
marker
.
annotationView
;
}
if
([
annotation
isKindOfClass
:[
MAPointAnnotation
class
]])
{
AMapMarker
*
marker
=
[
mapView
getMarker
:
annotation
];
return
marker
.
annotationView
;
...
...
lib/ios/react-native-amap3d.podspec
View file @
3d1c59fa
...
...
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s
.
license
=
package
[
'license'
]
s
.
platform
=
:ios
,
"8.0"
s
.
source
=
{
:git
=>
"http://git.wsc.tech/wangqb/react-native-amap3d"
}
s
.
source
=
{
:git
=>
"http://git.wsc.tech/wangqb/react-native-amap3d"
,
:tag
=>
"2.0dev"
}
s
.
source_files
=
'**/*.{h,m}'
s
.
dependency
'React'
...
...
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