iPhoneのルートメーイメージオーバーレイ
質問
私は自分のプロジェクトでRoute-Meを使用しています。図書館はとても良いです。マーカーの追加、ポリゴンの描画は正常に動作します。特定の場所(緯度、経度)にオーバーレイとして単一の画像を配置するのはどうですか?この機能は欠けていると思います。タイルのソースをオーバーロードせずに画像オーバーレイを配置する人はいますか?
解決
解決策を見つけました...
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 fileのどこかにあります
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];
CIAO!
- ランディ
所属していません StackOverflow