首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone中的route-me图像覆盖

iPhone中的route-me图像覆盖
EN

Stack Overflow用户
提问于 2011-07-25 03:10:30
回答 2查看 1.3K关注 0票数 3

我在我的项目中使用route-me。库是相当好的。添加标记,绘制多边形效果很好。在给定的位置(纬度,经度)放置单个图像作为覆盖如何?我认为这种趣味性缺失了。有没有人在不重载tiles源代码的情况下完成了图像覆盖?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-15 19:38:36

我已经找到解决方案了..。

代码语言:javascript
复制
 CLLocationCoordinate2D lcA =   CLLocationCoordinate2DMake(oSector.f_overlay_lat_min,oSector.f_overlay_long_min);
        CLLocationCoordinate2D lcB = CLLocationCoordinate2DMake(oSector.f_overlay_lat_max,oSector.f_overlay_long_max);

        CGPoint cgA = [mvMap latLongToPixel:lcA];
        CGPoint cgB = [mvMap latLongToPixel:lcB];

        float fLatMin  = MIN(cgA.x,cgB.x);
        float fLongMin = MIN(cgA.y,cgB.y);

        float fWidth  = sqrt((cgA.x - cgB.x)*(cgA.x - cgB.x));
        float fHeight = sqrt((cgA.y - cgB.y)*(cgA.y - cgB.y));

        RMMapLayer *mlLayer = [[RMMapLayer alloc] init];
        mlLayer.contents = (id) oSector.im_overlay.CGImage;
        mlLayer.frame    = CGRectMake(fLatMin,fLongMin,fWidth,fHeight); 

        [[mvMap.contents overlay] addSublayer:mlLayer];

mvMap是h文件中某处的IBOutlet RMMapView *mvMap

oSector.im_overlay.CGImage可以是

代码语言:javascript
复制
UIImage *i = [UIImage imageNamed:<something>];
lmLayer.contents = i.CGImage
票数 1
EN

Stack Overflow用户

发布于 2011-08-13 05:25:15

为什么不直接使用RMMarker呢?您可以将任何想要的图像应用于它,并根据需要放置它。如果您愿意,甚至可以将其设置为可拖动:

代码语言:javascript
复制
UIImage *imgLocation = [UIImage imageWithContentsOfFile :
                          [[NSBundle mainBundle] pathForResource:@"location_ind"      
                                                          ofType:@"png"]];
markerCurrentLocation = [[RMMarker alloc] initWithUIImage:imgLocation];
// make sure it is always above everything else.
markerCurrentLocation.zPosition = -1.0;
[mapView.markerManager addMarker:markerCurrentLocation
                       AtLatLong:startingPoint];

再见!

--兰迪

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6809023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档