Domanda

sto usando route-me nel mio progetto. Biblioteca è abbastanza buona. Aggiunta marcatori, bugne polygone bene. Come su come piazzare una sola immagine come sovrapposizione in data posizione (latitudine, longitudine)? Questa funzionalita 'manca credo. Qualcuno ha fatto mettendo la sovrapposizione di immagini senza sovraccaricare la fonte piastrelle?

È stato utile?

Soluzione

Ho trovato la soluzione ...

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

la mvMap è IBOutlet RMMapView * mvMap qualche parte nel file h

l'oSector.im_overlay.CGImage può essere

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

Altri suggerimenti

Perché non usare un RMMarker? È possibile applicare qualsiasi immagine che si desidera e posizionarlo in base alle esigenze. Anche lo rendono trascinabile se si desidera:

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top