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
b18d4565
Commit
b18d4565
authored
Jun 21, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现 iOS polygon 接口
parent
8608af77
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
115 additions
and
9 deletions
+115
-9
README.md
README.md
+3
-3
Polygon.js
components/Polygon.js
+6
-2
AMapPolygon.h
ios/AMapPolygon.h
+13
-0
AMapPolygon.m
ios/AMapPolygon.m
+56
-0
AMapPolygonManager.m
ios/AMapPolygonManager.m
+24
-0
AMapPolyline.h
ios/AMapPolyline.h
+3
-2
AMapPolyline.m
ios/AMapPolyline.m
+1
-1
AMapView.m
ios/AMapView.m
+5
-1
AMapViewManager.m
ios/AMapViewManager.m
+4
-0
No files found.
README.md
View file @
b18d4565
...
@@ -161,8 +161,8 @@ import MapView from 'react-native-amap3d'
...
@@ -161,8 +161,8 @@ import MapView from 'react-native-amap3d'
-
[
x
]
基本属性及事件
-
[
x
]
基本属性及事件
-
[
x
]
自定义信息窗体
-
[
x
]
自定义信息窗体
-
[
x
]
自定义图标
-
[
x
]
自定义图标
-
[
]
折线绘制(Polyline)🚀
-
[
x
]
折线绘制(Polyline)
-
[
]
多边形绘制(Polygon)
-
[
x
]
多边形绘制(Polygon)
-
[
]
圆形绘制(Circle)
-
[
]
圆形绘制(Circle)
🚀
-
[
]
POI 检索
-
[
]
POI 检索
-
[
]
地理编码转换
-
[
]
地理编码转换
components/Polygon.js
View file @
b18d4565
import
React
,
{
PropTypes
,
Component
}
from
'react'
import
React
,
{
PropTypes
,
Component
}
from
'react'
import
{
requireNativeComponent
,
View
,
PixelRatio
}
from
'react-native'
import
{
requireNativeComponent
,
View
,
PixelRatio
,
Platform
}
from
'react-native'
import
{
LatLng
}
from
'./PropTypes'
import
{
LatLng
}
from
'./PropTypes'
class
Polygon
extends
Component
{
class
Polygon
extends
Component
{
...
@@ -16,7 +16,11 @@ class Polygon extends Component {
...
@@ -16,7 +16,11 @@ class Polygon extends Component {
render
()
{
render
()
{
const
props
=
{
const
props
=
{
...
this
.
props
,
...
this
.
props
,
strokeWidth
:
PixelRatio
.
getPixelSizeForLayoutSize
(
this
.
props
.
strokeWidth
),
...
Platform
.
select
({
android
:
{
strokeWidth
:
PixelRatio
.
getPixelSizeForLayoutSize
(
this
.
props
.
strokeWidth
),
},
}),
}
}
return
<
AMapPolygon
{...
props
}
/
>
return
<
AMapPolygon
{...
props
}
/
>
}
}
...
...
ios/AMapPolygon.h
0 → 100644
View file @
b18d4565
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#pragma ide diagnostic ignored "OCUnusedPropertyInspection"
@interface
AMapPolygon
:
UIView
<
MAOverlay
>
@property
(
nonatomic
,
readonly
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
readonly
)
MAMapRect
boundingMapRect
;
-
(
MAOverlayRenderer
*
)
renderer
;
@end
ios/AMapPolygon.m
0 → 100644
View file @
b18d4565
#import "AMapPolygon.h"
#import "Coordinate.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation
AMapPolygon
{
MAPolygon
*
_polygon
;
MAPolygonRenderer
*
_renderer
;
CGFloat
_strokeWidth
;
UIColor
*
_strokeColor
;
UIColor
*
_fillColor
;
}
-
(
void
)
setCoordinates
:
(
NSArray
<
Coordinate
*>
*
)
coordinates
{
CLLocationCoordinate2D
coords
[
coordinates
.
count
];
for
(
NSUInteger
i
=
0
;
i
<
coordinates
.
count
;
i
++
)
{
coords
[
i
]
=
coordinates
[
i
].
coordinate
;
}
if
(
_strokeColor
==
nil
)
{
_strokeColor
=
UIColor
.
blackColor
;
}
_polygon
=
[
MAPolygon
polygonWithCoordinates
:
coords
count
:
coordinates
.
count
];
_renderer
=
[[
MAPolygonRenderer
alloc
]
initWithPolygon
:
_polygon
];
_renderer
.
lineWidth
=
_strokeWidth
;
_renderer
.
strokeColor
=
_strokeColor
;
_renderer
.
fillColor
=
_fillColor
;
}
-
(
void
)
setStrokeWidth
:
(
CGFloat
)
strokeWidth
{
_strokeWidth
=
strokeWidth
;
_renderer
.
lineWidth
=
strokeWidth
;
}
-
(
void
)
setStrokeColor
:
(
UIColor
*
)
strokeColor
{
_strokeColor
=
strokeColor
;
_renderer
.
strokeColor
=
strokeColor
;
}
-
(
void
)
setFillColor
:
(
UIColor
*
)
fillColor
{
_fillColor
=
fillColor
;
_renderer
.
fillColor
=
fillColor
;
}
-
(
CLLocationCoordinate2D
)
coordinate
{
return
_polygon
.
coordinate
;
}
-
(
MAMapRect
)
boundingMapRect
{
return
_polygon
.
boundingMapRect
;
}
-
(
MAOverlayRenderer
*
)
renderer
{
return
_renderer
;
}
@end
ios/AMapPolygonManager.m
0 → 100644
View file @
b18d4565
#import <MAMapKit/MAMapView.h>
#import <React/RCTViewManager.h>
#import "AMapPolygon.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface
AMapPolygonManager
:
RCTViewManager
<
MAMapViewDelegate
>
@end
@implementation
AMapPolygonManager
{
}
RCT_EXPORT_MODULE
()
-
(
UIView
*
)
view
{
return
[
AMapPolygon
new
];
}
RCT_EXPORT_VIEW_PROPERTY
(
coordinates
,
CoordinateArray
)
RCT_EXPORT_VIEW_PROPERTY
(
strokeWidth
,
CGFloat
)
RCT_EXPORT_VIEW_PROPERTY
(
strokeColor
,
UIColor
)
RCT_EXPORT_VIEW_PROPERTY
(
fillColor
,
UIColor
)
@end
ios/AMapPolyline.h
View file @
b18d4565
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
#import <MAMapKit/MAMapKit.h>
#import <MAMapKit/MAMapKit.h>
#pragma ide diagnostic ignored "OCUnusedPropertyInspection"
@interface
AMapPolyline
:
UIView
<
MAOverlay
>
@interface
AMapPolyline
:
UIView
<
MAOverlay
>
@property
(
nonatomic
,
readonly
)
CLLocationCoordinate2D
coordinate
;
@property
(
nonatomic
,
readonly
)
CLLocationCoordinate2D
coordinate
;
...
@@ -8,4 +10,4 @@
...
@@ -8,4 +10,4 @@
-
(
MAOverlayRenderer
*
)
renderer
;
-
(
MAOverlayRenderer
*
)
renderer
;
@end
@end
\ No newline at end of file
ios/AMapPolyline.m
View file @
b18d4565
...
@@ -16,10 +16,10 @@
...
@@ -16,10 +16,10 @@
for
(
NSUInteger
i
=
0
;
i
<
coordinates
.
count
;
i
++
)
{
for
(
NSUInteger
i
=
0
;
i
<
coordinates
.
count
;
i
++
)
{
coords
[
i
]
=
coordinates
[
i
].
coordinate
;
coords
[
i
]
=
coordinates
[
i
].
coordinate
;
}
}
_polyline
=
[
MAPolyline
polylineWithCoordinates
:
coords
count
:
coordinates
.
count
];
if
(
_color
==
nil
)
{
if
(
_color
==
nil
)
{
_color
=
UIColor
.
blackColor
;
_color
=
UIColor
.
blackColor
;
}
}
_polyline
=
[
MAPolyline
polylineWithCoordinates
:
coords
count
:
coordinates
.
count
];
_renderer
=
[[
MAPolylineRenderer
alloc
]
initWithPolyline
:
_polyline
];
_renderer
=
[[
MAPolylineRenderer
alloc
]
initWithPolyline
:
_polyline
];
_renderer
.
lineWidth
=
_width
;
_renderer
.
lineWidth
=
_width
;
_renderer
.
strokeColor
=
_color
;
_renderer
.
strokeColor
=
_color
;
...
...
ios/AMapView.m
View file @
b18d4565
#import "AMapView.h"
#import "AMapView.h"
#import "AMapMarker.h"
#import "AMapMarker.h"
#import "AMapPolyline.h"
#import "AMapPolyline.h"
#import "AMapPolygon.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
...
@@ -32,7 +33,7 @@
...
@@ -32,7 +33,7 @@
((
AMapMarker
*
)
subview
).
mapView
=
self
;
((
AMapMarker
*
)
subview
).
mapView
=
self
;
[
self
addAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
[
self
addAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
}
}
if
([
subview
isKindOfClass
:[
AMapPolyline
class
]])
{;
if
([
subview
isKindOfClass
:[
AMapPolyline
class
]]
||
[
subview
isKindOfClass
:[
AMapPolygon
class
]]
)
{;
[
self
addOverlay
:(
id
<
MAOverlay
>
)
subview
];
[
self
addOverlay
:(
id
<
MAOverlay
>
)
subview
];
}
}
}
}
...
@@ -41,6 +42,9 @@
...
@@ -41,6 +42,9 @@
if
([
subview
isKindOfClass
:[
AMapMarker
class
]])
{
if
([
subview
isKindOfClass
:[
AMapMarker
class
]])
{
[
self
removeAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
[
self
removeAnnotation
:(
id
<
MAAnnotation
>
)
subview
];
}
}
if
([
subview
isKindOfClass
:[
AMapPolyline
class
]]
||
[
subview
isKindOfClass
:[
AMapPolygon
class
]])
{
[
self
removeOverlay
:(
id
<
MAOverlay
>
)
subview
];
}
}
}
@end
@end
ios/AMapViewManager.m
View file @
b18d4565
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#import "AMapView.h"
#import "AMapView.h"
#import "AMapMarker.h"
#import "AMapMarker.h"
#import "AMapPolyline.h"
#import "AMapPolyline.h"
#import "AMapPolygon.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
#pragma ide diagnostic ignored "-Woverriding-method-mismatch"
#pragma ide diagnostic ignored "-Woverriding-method-mismatch"
...
@@ -88,6 +89,9 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
...
@@ -88,6 +89,9 @@ RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
if
([
overlay
isKindOfClass
:[
AMapPolyline
class
]])
{
if
([
overlay
isKindOfClass
:[
AMapPolyline
class
]])
{
return
((
AMapPolyline
*
)
overlay
).
renderer
;
return
((
AMapPolyline
*
)
overlay
).
renderer
;
}
}
if
([
overlay
isKindOfClass
:[
AMapPolygon
class
]])
{
return
((
AMapPolygon
*
)
overlay
).
renderer
;
}
return
nil
;
return
nil
;
}
}
...
...
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