我正在我的项目中使用路线。图书馆很好。添加标记,绘制多边形工作正常。在给定位置(纬度,经度)中将单个图像作为覆盖层如何?我认为缺少这种汇合。是否有人在不超载图块源的情况下放置图像叠加?

有帮助吗?

解决方案

我找到了解决方案...

 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是iboutlet rmmapview *mvmap在h文件中的某个地方

osector.im_overlay.cgimage可以是

UIImage *i = [UIImage imageNamed:<something>];
lmLayer.contents = i.CGImage

其他提示

为什么不使用rmmarker?您可以将您想要的任何图像应用于它并根据需要放置。如果您想:

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];

再见!

- 兰迪

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top