用到的类 CLGeocoder,用来将输入的地名编码为CLPlacemark,CLPlacemark封装了一地理信息
上代码
- (void)gencodeQuery :(NSString*)place
{
CLGeocoder *geocoder = [[CLGeocoder alloc]init];
//对地理位置进行编码
[geocoder geocodeAddressString:place completionHandler:^(NSArray *placemarks,NSError *error){
for (int i = 0; i != placemarks.count; ++i)
{
CLPlacemark *placemark = placemarks[i];
//地图进行缩放,第一个参数是中心,第二个参数是南北跨度,第三个参数是东西跨度
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(placemark.location.coordinate, 30000, 30000);
[mapView setRegion:region];
//在地图上添加标注,MapLocation是自定义类,实现了MKAnnotation协议
MapLocation *annotation = [[MapLocation alloc]init];
annotation.streetAddress = placemark.thoroughfare;
annotation.city = placemark.locality;
annotation.state = placemark.administrativeArea;
annotation.zip = placemark.postalCode;
annotation.coordinate = placemark.location.coordinate;
//添加标注,添加后回回调MKMapViewDelegate的
//- (MKAnnotationView*)mapView:(MKMapView *)parmMapView viewForAnnotation:(id<MKAnnotation>)annotation
//自定义MapLocation的原因是addAnnotation接收id <MKAnnotation>参数
[mapView addAnnotation:annotation];
}
}];
}
#pragma MKMapViewDelegate
- (MKAnnotationView*)mapView:(MKMapView *)parmMapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKPinAnnotationView *animationView = (MKPinAnnotationView*)[parmMapView dequeueReusableAnnotationViewWithIdentifier:@"T"];
if(animationView == nil)
animationView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@"T"];
animationView.pinColor = MKPinAnnotationColorGreen;//设置标注的颜色
animationView.animatesDrop = YES;//设置动画
animationView.canShowCallout = YES;//显示详细信息当点击标注的时候
return animationView;
}
自定义的类
@interface MapLocation : NSObject<MKAnnotation>
@property(nonatomic,readwrite) CLLocationCoordinate2D coordinate;
@property(nonatomic,strong) NSString *streetAddress;
@property(nonatomic,strong) NSString *city;
@property(nonatomic,strong) NSString *state;
@property(nonatomic,strong) NSString *zip;
@end
-------------
@implementation MapLocation
- (NSString*)title
{
return@"您的位置!";
}
- (NSString*)subtitle
{
NSString *ret = @"";
ret = [ret stringByAppendingString:self.state];
ret = [ret stringByAppendingString:self.city];
return ret;
}
@end
1、开机动画程序bootanimation
程序目录:frameworks/base/cmds/bootanimation
主要文件:frameworks/base/cmds/bootanimation/BootAnimation.cpp
调用位置: 在init.rc中调用bootanimation
2、bootanimation流程
2.1 显示方式
判断是否存在"/data/local/bootanimation.zip"或"/system/media/bootanimation.zip",
若存在的话,则显示bootanimation.zip中的动画;
若不存在的话,则显示系统默认的android闪动画面。
具体的代码(在BootAnimation.cpp中):
--> readyToRun()中判断bootanimation.zip是否存在
--> threadLoop()中根据mAndroidAnimation的值,来区分不同的显示方式
--> 若mAndroidAnimation为true,则显示默认的动画,调用android()
若mAndroidAnimation为false,则显示bootanimation.zip中的动画,调用movie()
用一个java中的 Runtime.getRuntime().exec(cmd)停止和启动linux中tomcat
在这里我只写一个启动tomcat的脚本 停止的自己做
1.首先写一个脚本 start.sh
#!/bin/sh
cd /usr/tomcat4/apache-tomcat-5.5.12/bin
sh startup.sh
2.写一个页面(这里我用servlet)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String sh = "/bin/sh";
String param = "-c";
String realcmd = "/usr/richstat/start.sh"; //我脚本放置的位置
String[] cmd={sh,param,realcmd};
try
{
Process p = Runtime.getRuntime().exec(cmd); //主要的是这个详细查jdk文档
}
catch(Exception e)
{
e.printStackTrace();
}
}
3.配置web.xml
<servlet>
<servlet-name>start</servlet-name>
<servlet-class>tomcat.StartupTomcat</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>start</servlet-name>
<url-pattern>/start</url-pattern>
</servlet-mapping>
4.执行url就可以了