Pregunta

Estoy usando Route-Me en mi proyecto. La biblioteca es bastante buena. Agregar marcadores, dibujar la polígona funciona bien. ¿Qué tal colocar una imagen única como superposición en la ubicación dada (latitud, longitud)? Creo que esta funcionalidad falta. ¿Alguien ha terminado de colocar la superposición de la imagen sin sobrecargar la fuente de mosaicos?

¿Fue útil?

Solución

He encontrado la solución ...

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

El mvmap es iBoutlet rmmapView *mvmap en algún lugar de su archivo h

Osector.im_overlay.cgimage puede ser

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

Otros consejos

¿Por qué no usar un RMMarker? Puede aplicar cualquier imagen que desee y colocarla según sea necesario. Incluso hazlo arrastrable si quieres:

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!

- Randy

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top