All Projects → CXTretar → CXProvincesMapView

CXTretar / CXProvincesMapView

Licence: MIT license
一个基于PaintCode绘制的中国省份地图框架

Programming Languages

objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to CXProvincesMapView

mapchina
R Package of Geospatial Shapefile of China Administrative Divisions to the County/District-Level.
Stars: ✭ 60 (+22.45%)
Mutual labels:  map, china
Highcharts China Geo
Highcharts 中国地图,Highcharts 中国省市地图,Highcharts China Map,南海诸岛geo
Stars: ✭ 29 (-40.82%)
Mutual labels:  map, china
China Geojson
最新中国地图json文件,可用d3开发中国地图
Stars: ✭ 181 (+269.39%)
Mutual labels:  map, china
kerala-dashboard
Kerala COVID-19 Dashboard
Stars: ✭ 25 (-48.98%)
Mutual labels:  map
MinedMap
Minecraft map renderer and viewer
Stars: ✭ 35 (-28.57%)
Mutual labels:  map
amap
行政区域查询,根据经纬度快速地查找特定的行政区域信息、省市区信息、中国省市区数据。Administrative region query: to quickly find specific administrative region information based on latitude and longitude provincial information urban China data
Stars: ✭ 31 (-36.73%)
Mutual labels:  map
typhoon-iran-cities
A Laravel package for importing regions of Iran such as provinces, counties, sectors, cities, city districts, rural districts, and villages of Iran into your database accurately. پکیج لاراول برای افزودن شهرها و استان ها و تمام مناطق روستایی و بخش های ایران
Stars: ✭ 31 (-36.73%)
Mutual labels:  provinces
papyruscs
PapyrusCS renders maps of Minecraft: Bedrock Edition worlds using C#, LevelDB and leaflet.
Stars: ✭ 221 (+351.02%)
Mutual labels:  map
let-it-be
中国高等教育群体的心理健康状态数据集
Stars: ✭ 28 (-42.86%)
Mutual labels:  china
examples-android
Android demo application for GLMap framework
Stars: ✭ 14 (-71.43%)
Mutual labels:  map
HMap
:earth: HMap | 基于openlayers的封装组件
Stars: ✭ 64 (+30.61%)
Mutual labels:  map
china-topdeveloper
Google Play中国顶尖开发者名单,后续更新
Stars: ✭ 22 (-55.1%)
Mutual labels:  china
geo-tree
High performance library for geographical map-related operations
Stars: ✭ 51 (+4.08%)
Mutual labels:  map
vue-qqmap
基于Vue3的腾讯地图地址可视化拾取、描点,路径规划插件
Stars: ✭ 21 (-57.14%)
Mutual labels:  map
adaptive-composite-map-projections
Adaptive composite map projections combine several projections
Stars: ✭ 64 (+30.61%)
Mutual labels:  map
map-keys-deep-lodash
Map/rename keys recursively with Lodash
Stars: ✭ 16 (-67.35%)
Mutual labels:  map
nycbikemap
A web-based, unified, interactive bike map for NYC that combines information from NYC OpenData, Citi Bike and other sources.
Stars: ✭ 15 (-69.39%)
Mutual labels:  map
node-isochrone
NodeJS isochrone map library
Stars: ✭ 27 (-44.9%)
Mutual labels:  map
mapr
Map species occurrence data
Stars: ✭ 34 (-30.61%)
Mutual labels:  map
o2d3m
Wavefront OBJ to Doom3 map converter.
Stars: ✭ 15 (-69.39%)
Mutual labels:  map

CXProvincesMapView

CXProvincesMapView

关于自定义 MapPath 的数据获取可以看下这里 使用 PaintCode 绘制自定义的省份地图控件

Update【更新】

  • 10.17 新增了图钉点击效果,可以添加自定义视图
  • 10.22 增加了新的构造方法,提供外部传入 mapPath 参数, 修复了PinView的大小计算Bug,Demo增加了福建省的数据以及视图

Install【安装】

在Podfile文件中添加pod 'CXProvincesMapView',并运行 pod install

Usage【使用】

  • import【导入框架】 #import "CXProvincesMapView.h"

  • custom【自定义属性】

@property(nonatomic, assign) NSInteger selectedIndex;      // 选中省份的index
@property(nonatomic, strong) UIColor *fillColor;           // 省份的背景颜色
@property(nonatomic, strong) UIColor *fillSelectedColor;   // 选中省份的背景颜色
@property(nonatomic, strong) UIColor *strokeColor;         // 省份边界的颜色
@property(nonatomic, strong) UIColor *strokeSelectedColor; // 选中省份边界的颜色
@property(nonatomic, strong) UIColor *textColor;           // 省份字体的颜色
@property(nonatomic, strong) UIColor *textSelectedColor;   // 选中省份字体的颜色

@property(nonatomic, assign) CGFloat minimumZoomScale;     // default is 1.0
@property(nonatomic, assign) CGFloat maximumZoomScale;     // default is 2.0

@property(nonatomic, strong) UIView *pinView;              // 图钉自定义视图
@property(nonatomic, strong) UIImage *pinImage;            // 图钉图片
@property(nonatomic, assign) BOOL pinAnimation;            // default is YES 图钉是否动画

@property(nonatomic, weak) id <CXProvincesMapViewDelegate>delegate;

/// 自定义的地图快捷创建方法
/// @param mapPath svg 绘图数据
/// @param mapSize svg 绘图尺寸
/// @param frame   视图控件的frame
- (instancetype)initWithMapPath:(ChinaMapPath *)mapPath andMapSize:(CGSize)mapSize andFrame:(CGRect)frame;
  • example【示例】
//
//  SampleMapController.m
//  CXProvincesMapView
//
//  Created by Felix on 2019/4/22.
//  Copyright © 2019 CXTretar. All rights reserved.
//

#import "SampleMapController.h"
#import "CXProvincesMapView.h"

@interface SampleMapController ()<CXProvincesMapViewDelegate>

@property (nonatomic, strong) CXProvincesMapView *chinaMapView;

@end

@implementation SampleMapController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"SampleMapController";
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    self.chinaMapView = [[CXProvincesMapView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)];
    _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0];
    _chinaMapView.maximumZoomScale = 5.0;
    _chinaMapView.delegate = self;
    _chinaMapView.center = self.view.center;
//    _chinaMapView.pinAnimation = NO;
    // 直接设置图片
//    _chinaMapView.pinImage = [UIImage imageNamed:@"pin"];
    // 添加按钮点击
    UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds];
    [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal];
    [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside];
    [_chinaMapView.pinView addSubview:pinButton];
    
    [self.view addSubview:_chinaMapView];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    //
    if (self.view.bounds.size.width > self.view.bounds.size.height) {
        self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400);
    } else {
        self.chinaMapView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400);
    }
    self.chinaMapView.center = self.view.center;
}

- (void)selectProvinceAtIndex:(NSInteger)index andName:(NSString *)name {
    NSLog(@"Province - %ld - %@", (long)index, name);
    self.title = [NSString stringWithFormat:@"Province - %ld - %@", (long)index, name];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    _chinaMapView.selectedIndex = 0;
    _chinaMapView.fillColor = [UIColor cyanColor];
    _chinaMapView.fillSelectedColor = [UIColor greenColor];
    _chinaMapView.strokeColor = [UIColor whiteColor];
    _chinaMapView.strokeSelectedColor = [UIColor greenColor];
    _chinaMapView.textColor = [UIColor blueColor];
    _chinaMapView.textSelectedColor = [UIColor orangeColor];
    
}

- (void)pinTest {
    NSLog(@"%s", __func__);
}

- (void)dealloc {
    NSLog(@"%s", __func__);
}

@end


  • 自定义的mapPath (mapPath 类继承 ChinaMapPath.h)【示例】
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // 福建省市数据
    FujianMapPath *mapPath = [[FujianMapPath alloc] init];
    self.chinaMapView = [[CXProvincesMapView alloc]initWithMapPath:mapPath andMapSize:CGSizeMake(308, 340) andFrame:CGRectMake(0, 0, self.view.bounds.size.width, 400)];
    _chinaMapView.backgroundColor = [UIColor colorWithRed:230/255.0 green:1.0 blue:1.0 alpha:1.0];
    _chinaMapView.maximumZoomScale = 5.0;
    _chinaMapView.center = self.view.center;
    _chinaMapView.delegate = self;
    //    _chinaMapView.pinAnimation = NO;
    // 直接设置图片
    //    _chinaMapView.pinImage = [UIImage imageNamed:@"pin"];
    // 添加按钮点击
    UIButton *pinButton = [[UIButton alloc]initWithFrame:_chinaMapView.pinView.bounds];
    [pinButton setImage:[UIImage imageNamed:@"pin"] forState:UIControlStateNormal];
    [pinButton addTarget:self action:@selector(pinTest) forControlEvents:UIControlEventTouchUpInside];
    [_chinaMapView.pinView addSubview:pinButton];
    [self.view addSubview:_chinaMapView];
}

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].