iOS 地图(自定义地位图标)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; self.window.rootViewController = [[RootViewController alloc] init]; [self.window makeKeyAndVisible];
return YES;
} @end
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
#import "RootViewController.h"
#import <MapKit/MapKit.h>
#import "YXYCAnation.h"
@interface RootViewController ()<MKMapViewDelegate> @end @implementation RootViewController - (void)viewDidLoad {
[super viewDidLoad];
// 初始化MKMapView
MKMapView *mapView = [[MKMapView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 设置代理
mapView.delegate = self;
// 设置显示当前位置
mapView.showsUserLocation = YES;
// 设置地图显示类型
mapView.mapType = MKMapTypeStandard;
// 经纬度
CLLocationCoordinate2D coord2D = {23.117000,113.27500};
// 显示范围精度
MKCoordinateSpan span = {0.01,0.01};
// 显示区域
MKCoordinateRegion region = {coord2D,span};
// 给地图设置显示区域
[mapView setRegion:region animated:YES];
[self.view addSubview:mapView]; // 创建anation对象
CLLocationCoordinate2D showCoord = {23.117000,113.27500};
YXYCAnation *anation1 = [[YXYCAnation alloc] initWithCoordinate2D:showCoord];
anation1.title = @"越秀公园";
anation1.subtitle = @"小标题";
[mapView addAnnotation:anation1];
} #pragma mark -MKAnnotationView delegate-
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *identifier = @"Annotion";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotationView reuseIdentifier:identifier];
annotationView.image = [UIImage imageNamed:@""];
}
return annotationView;
} - (void)buttonAction:(UIButton *)sender
{
NSLog(@"显示公园简介");
} @end
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface YXYCAnation : NSObject<MKAnnotation> @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle; - (id)initWithCoordinate2D:(CLLocationCoordinate2D)coordinate; @end
#import "YXYCAnation.h" @implementation YXYCAnation - (id)initWithCoordinate2D:(CLLocationCoordinate2D)coordinate
{
self = [super init];
if (self != nil) {
_coordinate = coordinate;
}
return self;
} @end
iOS 地图(自定义地位图标)的更多相关文章
- CSS学习笔记----CSS3自定义字体图标
响应式网页字体图标 作者:大漠 日期:2014-01-28 点击:3220 @font-face Responsive 本文由大漠根据Jason的<Responsive Webfont Icon ...
- Android高德地图自定义Markers的例子
下文为各位重点介绍关于Android高德地图自定义Markers的例子,希望这篇文章能够让各位理解到Android高德地图自定义Markers的方法. 之前的博客里说了地图的嵌入和定位,今天就说说在地 ...
- 【高德API】如何利用MapKit开发全英文检索的iOS地图
原文:[高德API]如何利用MapKit开发全英文检索的iOS地图 制作全英文地图的展示并不困难,但是要制作全英文的数据检索列表,全英文的信息窗口,你就没办法了吧.告诉你,我有妙招!使用iOS自带的M ...
- 百度地图自定义icon,定位偏移问题
最近使用百度地图做一个调度系统,使用定义icon的marker,结果地图显示marker和实际位置偏移,最终参考文章: http://www.cnblogs.com/jz1108/archive/20 ...
- 【iOS地图开发】巧妙打造中英文全球地图
地图开发的同学们经常遇到这样的问题,国内版地图开发,用高德或者百度就行了.但是,国外的地图怎么办?这里告诉大家,如果利用iOS地图,打造中英文的,国内国外都能用的,全球地图. 制作全英文地图的展示并不 ...
- 自定义iconfont 图标库下载本地在移动App的使用及svg彩色图标
自定义iconfont 图标库扩展 在Hbuilder开发移动App的使用及svg彩色图标(或mui图标库的自定义扩展) 前提准备:1.登录阿里iconfont图标库,创建自己的项目,地址:http: ...
- 在项目中增加自定义icon图标
以MUI框架为例,内容来自于MUI官网. mui如何增加自定义icon图标 mui框架遵循极简原则,在icon图标集上也是如此,mui仅集成了原生系统中最常用的图标:其次,mui中的图标并不是图片,而 ...
- iOS 如何自定义UISearchBar 中textField的高度
iOS 如何自定义UISearchBar 中textField的高度 只需设置下边的方法就可以 [_searchBar setSearchFieldBackgroundImage:[UIImage i ...
- iOS 隐藏自定义tabbar
iOS 隐藏自定义tabbar -(void)viewWillAppear:(BOOL)animated { NSArray *array=self.tabBarController.view.su ...
随机推荐
- 解析Ceph: 数据的端到端正确性和 Scrub 机制
转自:https://www.ustack.com/blog/ceph-internal-scrub/ Ceph 的主要一大特点是强一致性,这里主要指端到端的一致性.众所周知,传统存储路径上从应用层到 ...
- linux 下sed命令
sed命令是一个面向字符流的非交互式编辑器,也就是说sed不允许用户与它进行交互操作.sed是按行来处理文本内容的.在shell中,使用sed来批量修改文本内容是非常方便的. sed [选项] [动作 ...
- LeetCode OJ:Binary Tree Inorder Traversal(中序遍历二叉树)
Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...
- LeetCode OJ:Count Complete Tree Nodes(完全二叉树的节点数目)
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from W ...
- hdoj-1004-Let the Balloon Rise(map排序)
map按照value排序 #include <iostream> #include <algorithm> #include <cstring> #include ...
- 20165210 Java第三周学习总结
20165210 Java第三周学习总结 教材学习内容总结 - 第四章学习总结 编程语言的几个发展阶段: 面向机器语言 面向过程语言 面向对象语言 类: 类声明: class People { ... ...
- uva489(需要考虑周全)
这个题是简单题,但是我的思路本身不周全,忽略了一种比较“无理”的情况,而导致WA多次.我是把猜的串全扫一遍以后判断出结果,但是实际上可能是前面已经全猜对了,但是这个选手是个逗比,已经猜对了还要猜,而且 ...
- enumerate 枚举
- SVN客户端与服务器端搭建
一.客户端安装 1.点击安装程序 2.修改svn安装位置 3.开始安装 4.安装完成 5.回到左面 右键出现svn检出 tortoiSVN 表示安装成功 二.SVN服务端安装 1.点击服务端安装 ...
- c# Http请求之HttpClient
利用HttpClient进行Http请求,基于此,简单地封装了下: using System; using System.Collections.Generic; using System.Colle ...