读书人

ios googlemap 平添map overlay

发布时间: 2012-07-24 17:47:58 作者: rapoo

ios googlemap 添加map overlay

?

?画线

?

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{//    float zoom = 0.000004/zoomScale;    MKMapRect  theMapRect = [self.overlayboundingMapRect];    CGRect theRect = [selfrectForMapRect:theMapRect];        CGContextSetAlpha(context, 0.5);    //    CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);//    CGContextFillRect(context, theRect);//    CGContextAddRect(context, theRect);//    CGContextClip(context);    //    float w, h;//    w = theRect.size.width;//    h = theRect.size.height;//    //    CGContextSelectFont (context, // 3//                         "Helvetica-Bold",//                         h/10,//                         kCGEncodingMacRoman);//    CGContextSetCharacterSpacing (context, 10); // 4//    CGContextSetTextDrawingMode (context, kCGTextFillStroke); // 5//    //    CGContextSetRGBFillColor (context, 0, 1, 0, .5); // 6//    CGContextSetRGBStrokeColor (context, 0, 0, 1, 1); // 7//    CGAffineTransform myTextTransform =CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f );//    CGContextSetTextMatrix (context, myTextTransform); // 9//    CGPoint xx = [self pointForMapPoint:theMapRect.origin];//    CGContextShowTextAtPoint (context, xx.x, xx.y, "Quartz 2D", 9);          float w, h;    w = theRect.size.width;    h = theRect.size.height;    NSString *text = [selfgenerateText];//    CGContextSetAlpha(context, 0.5);    CGContextSetFillColorWithColor(context, [[UIColorblackColor] CGColor]);        char *commentsMsg;    commentsMsg = (char *)[text UTF8String];    CGContextSelectFont(context, "Helvetica-Bold", h, kCGEncodingMacRoman);// the h is the height of the text, it's key, because if it's small you can't see    CGContextSetTextDrawingMode(context, kCGTextFill);        CGAffineTransform myTextTransform =CGAffineTransformScale(CGAffineTransformIdentity, 1.f, -1.f );    CGContextSetTextMatrix (context, myTextTransform);    CGPoint xx = [selfpointForMapPoint:theMapRect.origin];    CGContextShowTextAtPoint(context,xx.x,xx.y,commentsMsg, strlen(commentsMsg));// the point must convert from mappoint to cgpoint    }
?

?

?

?

?

?

?

?

?

?

?

asdasd

读书人网 >操作系统

热点推荐