Skip to content

Commit

Permalink
实现 ios 海量点图层(MultiPoint)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Sep 3, 2017
1 parent 682c468 commit 5e7c482
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 3 deletions.
21 changes: 21 additions & 0 deletions example/ios/RNAMap3D/Images.xcassets/point.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "point.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions ios/AMapHeatMap.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#import <MAMapKit/MAMapKit.h>
#import "AMapModel.h"

#pragma ide diagnostic ignored "OCUnusedPropertyInspection"

@interface AMapHeatMap : AMapModel
@end
1 change: 0 additions & 1 deletion ios/AMapHeatMap.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "AMapHeatMap.h"
#import "Coordinate.h"

#pragma ide diagnostic ignored "OCUnusedMethodInspection"

Expand Down
7 changes: 7 additions & 0 deletions ios/AMapMultiPoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import <React/RCTComponent.h>
#import <MAMapKit/MAMapKit.h>
#import "AMapModel.h"

@interface AMapMultiPoint : AMapModel <MAMultiPointOverlayRendererDelegate>
@property(nonatomic, copy) RCTBubblingEventBlock onItemPress;
@end
38 changes: 38 additions & 0 deletions ios/AMapMultiPoint.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#import "AMapMultiPoint.h"

#pragma ide diagnostic ignored "OCUnusedMethodInspection"

@implementation AMapMultiPoint {
NSArray<MAMultiPointItem *> *_items;
MAMultiPointOverlayRenderer *_renderer;
MAMultiPointOverlay *_overlay;
UIImage *_image;
}

- (void)setPoints:(NSArray<MAMultiPointItem *> *)points {
_items = points;
}

- (void)setImage:(NSString *)name {
_image = [UIImage imageNamed:name];
}

- (MAOverlayRenderer *)renderer {
if (_renderer == nil) {
_overlay = [[MAMultiPointOverlay alloc] initWithMultiPointItems:_items];
_renderer = [[MAMultiPointOverlayRenderer alloc] initWithMultiPointOverlay:_overlay];
_renderer.delegate = self;
if (_image != nil) {
_renderer.icon = _image;
}
}
return _renderer;
}

- (void)multiPointOverlayRenderer:(MAMultiPointOverlayRenderer *)renderer didItemTapped:(MAMultiPointItem *)item {
self.onItemPress(@{
@"index": @([_items indexOfObject:item]),
});
}

@end
23 changes: 23 additions & 0 deletions ios/AMapMultiPointManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#import <MAMapKit/MAMapView.h>
#import <React/RCTViewManager.h>
#import "AMapMultiPoint.h"

#pragma ide diagnostic ignored "OCUnusedClassInspection"

@interface AMapMultiPointManager : RCTViewManager
@end

@implementation AMapMultiPointManager {
}

RCT_EXPORT_MODULE()

- (UIView *)view {
return [AMapMultiPoint new];
}

RCT_EXPORT_VIEW_PROPERTY(points, MAMultiPointItemArray)
RCT_EXPORT_VIEW_PROPERTY(image, NSString)
RCT_EXPORT_VIEW_PROPERTY(onItemPress, RCTBubblingEventBlock)

@end
7 changes: 7 additions & 0 deletions ios/RCTConvert+AMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ + (MAHeatMapNode *)MAHeatMapNode:(id)json {
return node;
}

+ (MAMultiPointItem *)MAMultiPointItem:(id)json {
MAMultiPointItem *item = [MAMultiPointItem new];
item.coordinate = [self CLLocationCoordinate2D:json];
return item;
}

+ (MACoordinateRegion)MACoordinateRegion:(id)json {
return MACoordinateRegionMake(
[self CLLocationCoordinate2D:json],
Expand All @@ -47,6 +53,7 @@ + (AMapNaviPoint *)AMapNaviPoint:(id)json {

RCT_ARRAY_CONVERTER(Coordinate)
RCT_ARRAY_CONVERTER(MAHeatMapNode)
RCT_ARRAY_CONVERTER(MAMultiPointItem)
RCT_ARRAY_CONVERTER(AMapNaviPoint)

@end

0 comments on commit 5e7c482

Please sign in to comment.