Commit 03089915 authored by 7c00's avatar 7c00

Add iOS MapView#locationStyle, close #151

parent 0e264650
......@@ -159,18 +159,6 @@ const coordinate = {
- [MultiPoint](https://github.com/qiuxiang/react-native-amap3d/blob/master/src/maps/MultiPoint.js)
## 关于问题反馈
- 提供你正在使用的版本、RN 版本、设备信息
- 请尽可能详细地描述问题
- 在提编译问题之前,请先检查最新的编译测试
以下情况 issue 会被 close:
- 确定是环境配置的问题,且没有提供足够的信息
- 问题不具备普遍性,且缺乏讨论
问题被关闭仍然欢迎继续讨论。
## 关于编译问题
鉴于编译问题重复提得太多,且没有什么讨论价值,有必要单独做一些说明。
......
......@@ -5,14 +5,14 @@ PODS:
- AMapNavi (5.2.1):
- AMap3DMap (>= 5.2.1)
- AMapFoundation (~> 1.4)
- React (0.50.3):
- React/Core (= 0.50.3)
- react-native-amap3d (0.7.3):
- React (0.51.0):
- React/Core (= 0.51.0)
- react-native-amap3d (0.10.1):
- AMapNavi
- React
- React/Core (0.50.3):
- yoga (= 0.50.3.React)
- yoga (0.50.3.React)
- React/Core (0.51.0):
- yoga (= 0.51.0.React)
- yoga (0.51.0.React)
DEPENDENCIES:
- React (from `../node_modules/react-native/`)
......@@ -31,9 +31,9 @@ SPEC CHECKSUMS:
AMap3DMap: 0614b5b7ed7a8b69f1d9ba7bc40ce30362497dc5
AMapFoundation: 6c0471c9a6a0ad17dad46e3d800ad56ca170f82a
AMapNavi: bb4d65295ed0ee0ad4b5f5792e9e2ea0e5117ffa
React: 0ba6cae888dc82dc47d6d5f3090615e1b5f6f3e7
react-native-amap3d: 9dfe63ac4831f77cd64078b318fe552a8ae3454f
yoga: faecc6be81ca7823ccbb470b93a1b228499fa1c0
React: 352f02f1db6e4744f9a758527e13e3fdefbbd6ba
react-native-amap3d: 136bc2c1d08f9672393e630b077495180c02f963
yoga: b5d96400ca8b2936965a7a6516da7c1177f432a3
PODFILE CHECKSUM: 518cbe237be8affd35ed7429281ba62b78ae3b2c
......
......@@ -110,6 +110,34 @@
remoteGlobalIDString = 2D02E47A1E0B4A5D006451C7;
remoteInfo = "RNAMap3D-tvOS";
};
39A967BE1FD00AEB0098651B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3DBE0D001F3B181A0099AA32;
remoteInfo = fishhook;
};
39A967C01FD00AEB0098651B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32;
remoteInfo = "fishhook-tvOS";
};
39A967D01FD00AEB0098651B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 9936F3131F5F2E4B0010BF04;
remoteInfo = privatedata;
};
39A967D21FD00AEB0098651B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 9936F32F1F5F2E5B0010BF04;
remoteInfo = "privatedata-tvOS";
};
39CBF08C1F4CA50E00E44A3F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
......@@ -415,6 +443,8 @@
children = (
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */,
39A967BF1FD00AEB0098651B /* libfishhook.a */,
39A967C11FD00AEB0098651B /* libfishhook-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
......@@ -448,6 +478,8 @@
39CBF08F1F4CA50E00E44A3F /* libthird-party.a */,
39CBF0911F4CA50E00E44A3F /* libdouble-conversion.a */,
39CBF0931F4CA50E00E44A3F /* libdouble-conversion.a */,
39A967D11FD00AEB0098651B /* libprivatedata.a */,
39A967D31FD00AEB0098651B /* libprivatedata-tvOS.a */,
);
name = Products;
sourceTree = "<group>";
......@@ -630,6 +662,9 @@
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = 23J47D8278;
};
2D02E47A1E0B4A5D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
ProvisioningStyle = Automatic;
......@@ -765,6 +800,34 @@
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
39A967BF1FD00AEB0098651B /* libfishhook.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libfishhook.a;
remoteRef = 39A967BE1FD00AEB0098651B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
39A967C11FD00AEB0098651B /* libfishhook-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libfishhook-tvOS.a";
remoteRef = 39A967C01FD00AEB0098651B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
39A967D11FD00AEB0098651B /* libprivatedata.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libprivatedata.a;
remoteRef = 39A967D01FD00AEB0098651B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
39A967D31FD00AEB0098651B /* libprivatedata-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libprivatedata-tvOS.a";
remoteRef = 39A967D21FD00AEB0098651B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
39CBF08D1F4CA50E00E44A3F /* libthird-party.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
......@@ -1133,6 +1196,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 23J47D8278;
INFOPLIST_FILE = RNAMap3D/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
......@@ -1140,7 +1204,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = cn.qiuxiang.native.example.RNAMap3D;
PRODUCT_NAME = RNAMap3D;
VERSIONING_SYSTEM = "apple-generic";
};
......@@ -1152,6 +1216,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 23J47D8278;
INFOPLIST_FILE = RNAMap3D/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
......@@ -1159,7 +1224,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = cn.qiuxiang.native.example.RNAMap3D;
PRODUCT_NAME = RNAMap3D;
VERSIONING_SYSTEM = "apple-generic";
};
......
......@@ -15,7 +15,7 @@ RCT_EXPORT_METHOD(distance:(double)lat1
lat2:(double)lat2
lng2:(double)lng2
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject ) {
reject:(RCTPromiseRejectBlock)reject) {
resolve(@(MAMetersBetweenMapPoints(
MAMapPointForCoordinate(CLLocationCoordinate2DMake(lat1, lng1)),
MAMapPointForCoordinate(CLLocationCoordinate2DMake(lat2, lng2))
......
#import <MAMapKit/MAMapKit.h>
@interface LocationStyle : NSObject
@property(nonatomic, strong) UIImage *image;
@property(nonatomic, strong) UIColor *fillColor;
@property(nonatomic, strong) UIColor *stokeColor;
@property(nonatomic, assign) CGFloat stokeWidth;
@end
\ No newline at end of file
#import "LocationStyle.h"
@implementation LocationStyle
@end
\ No newline at end of file
......@@ -3,6 +3,7 @@
#import <React/RCTConvert.h>
#import <React/RCTConvert+CoreLocation.h>
#import "Coordinate.h"
#import "LocationStyle.h"
@implementation RCTConvert (AMapView)
......@@ -24,6 +25,15 @@ RCT_ENUM_CONVERTER(MAPinAnnotationColor, (@{
return [[Coordinate alloc] initWithCoordinate:[self CLLocationCoordinate2D:json]];
}
+ (LocationStyle *)LocationStyle:(id)json {
LocationStyle *locationStyle = [LocationStyle new];
locationStyle.fillColor = [self UIColor:json[@"fillColor"]];
locationStyle.stokeColor = [self UIColor:json[@"stokeColor"]];
locationStyle.stokeWidth = [self CGFloat:json[@"stokeWidth"]];
locationStyle.image = [UIImage imageNamed:[self NSString:json[@"image"]]];
return locationStyle;
}
+ (MAHeatMapNode *)MAHeatMapNode:(id)json {
MAHeatMapNode *node = [MAHeatMapNode new];
node.coordinate = [self CLLocationCoordinate2D:json];
......
......@@ -2,11 +2,13 @@
#import "AMapView.h"
#import "AMapMarker.h"
#import "AMapPolyline.h"
#import "LocationStyle.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation AMapView {
NSMutableDictionary *_markers;
MAUserLocationRepresentation *_locationStyle;
}
- (instancetype)init {
......@@ -27,8 +29,8 @@
self.showsUserLocation = enabled;
}
- (void)setCoordinate:(CLLocationCoordinate2D)json {
self.centerCoordinate = json;
- (void)setCoordinate:(CLLocationCoordinate2D)coordinate {
self.centerCoordinate = coordinate;
}
- (void)setTilt:(CGFloat)degree {
......@@ -39,7 +41,18 @@
self.rotationDegree = degree;
}
// 不能直接 setRegion,因为如果地图未加载 setRegion 是无效的
- (void)setLocationStyle:(LocationStyle *)locationStyle {
if (!_locationStyle) {
_locationStyle = [MAUserLocationRepresentation new];
}
_locationStyle.fillColor = locationStyle.fillColor;
_locationStyle.strokeColor = locationStyle.stokeColor;
_locationStyle.lineWidth = locationStyle.stokeWidth;
_locationStyle.image = locationStyle.image;
[self updateUserLocationRepresentation:_locationStyle];
}
// 如果在地图未加载的时候调用改方法,需要先将 region 存起来,等地图加载完成再设置
- (void)setRegion:(MACoordinateRegion)region {
if (self.loaded) {
super.region = region;
......
......@@ -15,7 +15,7 @@ RCT_EXPORT_MODULE()
- (UIView *)view {
AMapView *mapView = [AMapView new];
mapView.centerCoordinate = CLLocationCoordinate2DMake(39.9042, 116.4074);
mapView.centerCoordinate = CLLocationCoordinate2DMake(39.9242, 116.3979);
mapView.zoomLevel = 10;
mapView.delegate = self;
return mapView;
......@@ -42,6 +42,7 @@ RCT_EXPORT_VIEW_PROPERTY(region, MACoordinateRegion)
RCT_EXPORT_VIEW_PROPERTY(tilt, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(rotation, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(distanceFilter, CLLocationDistance)
RCT_EXPORT_VIEW_PROPERTY(locationStyle, LocationStyle)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
......
{
"name": "react-native-amap3d",
"version": "0.10.1",
"version": "0.11.0",
"description": "react-native 高德地图组件",
"author": "Qiu Xiang <i@7c00.cc>",
"license": "MIT",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment