当前位置: 编程技术>移动开发
本页文章导读:
▪舆图应用的简单示例 地图应用的简单示例
首先,需要将CoreLocation.framework和MapKit.framework加入到项目中。
头文件:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface Locat.........
▪ 编码变换验证 编码转换验证
String param = req.getParameter("name_startsWith");
try {
System.out.println("param1====="+new String(param.getBytes("ISO-8859-1"), "GBK"));
System.out.println("param2====="+new String(param.getBytes("ISO-8859-1"), "GB231.........
▪ Ant的环境筹建 Ant的环境搭建
Apache Ant,是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用。默认情况下,脚本文件名为build.xml 。
Windows .........
[1]舆图应用的简单示例
来源: 互联网 发布时间: 2014-02-18
地图应用的简单示例
首先,需要将CoreLocation.framework和MapKit.framework加入到项目中。
头文件:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface LocationViewController : UIViewController <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
CLLocation *myLocation;
IBOutlet UIButton *getLocationBtn;
IBOutlet UILabel *latitudeLabel;
IBOutlet UILabel *longitudeLabel;
IBOutlet MKMapView *mapView;
}
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocation *myLocation;
@property (nonatomic, retain) UIButton *getLocationBtn;
@property (nonatomic, retain) UILabel *latitudeLabel;
@property (nonatomic, retain) UILabel *longitudeLabel;
@property (nonatomic, retain) MKMapView *mapView;
- (IBAction) getLocationBtnClicked:(id) sender;
- (void) initMapView;
- (void) initLocation;
@end
实现文件:
#import "LocationViewController.h"
@implementation LocationViewController
@synthesize locationManager;
@synthesize myLocation;
@synthesize getLocationBtn;
@synthesize latitudeLabel;
@synthesize longitudeLabel;
@synthesize mapView;
- (void)viewDidLoad {
[self initMapView];
[self initLocation];
[super viewDidLoad];
}
//初始化地图显示参数
- (void) initMapView {
//设定显示中心经纬度
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = 38.148926;
theCoordinate.longitude = -120.715542;
//设定显示范围
MKCoordinateSpan theSpan;
theSpan.latitudeDelta = 0.1;
theSpan.longitudeDelta = 0.1;
//设置地图显示的中心及范围
MKCoordinateRegion theRegion;
theRegion.center = theCoordinate;
theRegion.span = theSpan;
//设置地图显示的类型及根据范围进行显示
[self.mapView setMapType:MKMapTypeStandard];
[mapView setRegion:theRegion];
[mapView regionThatFits:theRegion];
//定位后在地图上用蓝色点显示用户的位置
mapView.showsUserLocation = YES;
}
//初始化定位相关参数
- (void) initLocation {
self.locationManager = [[CLLocationManager alloc] init];
//设置代理
locationManager.delegate = self;
//设置需要的定位精度
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
latitudeLabel.text = @"";
longitudeLabel.text = @"";
}
- (IBAction) getLocationBtnClicked:(id) sender {
latitudeLabel.text = @"";
longitudeLabel.text = @"";
//启动定位
[locationManager startUpdatingLocation];
}
- (void)dealloc {
[locationManager release];
[myLocation release];
[getLocationBtn release];
[latitudeLabel release];
[longitudeLabel release];
[mapView release];
[super dealloc];
}
//代理方法
#pragma mark -
#pragma mark CLLocationManagerDelegate Methods
//确定当前位置和位置更新了时调用这个方法
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
//获得定位点的纬度信息
NSString *latitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
latitudeLabel.text = latitudeString;
[latitudeString release];
//获得定位点的经度信息
NSString *longitudeString = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
longitudeLabel.text = longitudeString;
[longitudeString release];
//停止定位
[locationManager stopUpdatingLocation];
//把地图中心移动到定位到的这个点
[mapView setCenterCoordinate:newLocation.coordinate animated:YES];
//重新设置地图显示的区域
MKCoordinateSpan newSpan;
newSpan.latitudeDelta = 0.05;
newSpan.longitudeDelta = 0.05;
MKCoordinateRegion newRegion;
newRegion.center = newLocation.coordinate;
newRegion.span = newSpan;
[mapView setRegion:newRegion animated:YES];
}
//位置查询遇到错误时调用这个方法
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSString *errorType = (error.code == kCLErrorDenied) ?
@"Access Denied" : @"Unknown Error";
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error getting Location"
message:errorType
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
@end
[2] 编码变换验证
来源: 互联网 发布时间: 2014-02-18
编码转换验证
String param = req.getParameter("name_startsWith");
try {
System.out.println("param1====="+new String(param.getBytes("ISO-8859-1"), "GBK"));
System.out.println("param2====="+new String(param.getBytes("ISO-8859-1"), "GB2312"));
System.out.println("param3====="+new String(param.getBytes("ISO-8859-1"), "UTF-8"));
System.out.println("param4====="+new String(param.getBytes("GB2312"), "ISO-8859-1"));
System.out.println("param5====="+new String(param.getBytes("GB2312"), "GB2312"));
System.out.println("param6====="+new String(param.getBytes("GB2312"), "UTF-8"));
System.out.println("param7====="+new String(param.getBytes("GBK"), "ISO-8859-1"));
System.out.println("param8====="+new String(param.getBytes("GBK"), "UTF-8"));
System.out.println("param9====="+new String(param.getBytes("GBK"), "GB2312"));
System.out.println("param10====="+new String(param.getBytes("UTF-8"), "GBK"));
System.out.println("param11====="+new String(param.getBytes("UTF-8"), "GB2312"));
System.out.println("param12====="+new String(param.getBytes("UTF-8"), "ISO-8859-1"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
[3] Ant的环境筹建
来源: 互联网 发布时间: 2014-02-18
Ant的环境搭建
下载最新版本,ANT官方网站: http://ant.apache.org/ 下载后解压缩即可。
配置环境变量:
推荐:java环境变量设置,http://www./java-other/172921.html
Apache Ant,是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用。默认情况下,脚本文件名为build.xml 。
Windows 下的安装和配置 安装步骤:打开环境变量配置窗口可以通过下面步骤打开:我的电脑(Vista之后叫 计算机) –> 右键属性菜单点击 –> 高级(Vista之后是 高级系统设置) –> 点击环境变量按钮(如下图:)
然后在随后出现的环境变量窗口中的系统变量这里,增加下面的两个设置:
- ANT_HOME:C:\apache-ant-1.7.1 (这里为你自己解压缩的目录)
- PATH:%ANT_HOME%\bin (这个设置是为了方便在dos环境下操作)
完成上述步骤,就安装完毕。
查看是否安装成功。
在dos窗口中输入命令ant,若出现结果:
Buildfile:build.xml does not exist!
Build failed
说明ant安装成功!因为ant默认运行build.xml文件,这个文件需要我们建立。
一个简单的使用ANT的例子
在 D 盘根目录下新建一个 build.xml 文件,文件的内容如下:
<?xml version="1.0" encoding="GBK"?>
<project name="测试脚本" default="copyfile" basedir="." >
<target name="copyfile">
<copy file="d:/a.txt" todir="e:/Temp" overwrite="true" />
</target>
</project>
在 D 盘根目录下新建一个 a.txt 文件,内容随便。
进入DOS,依次执行:
d:
ant
如同下面的截图:
执行完毕后,我们会在 e:/Temp 目录下看到 a.txt 文件,跟D盘根目录下的完全一样,即Copy成功。
如果中间提示类似如下错误:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
这是因为JDK 的安装有问题或者是 JAVA_HOME 环境变量没有设置或者设置有问题, jre下肯定没tools.jar。
推荐:java环境变量设置,http://www./java-other/172921.html
最新技术文章: