Question

J'utilise moi la route dans mon projet. Bibliothèque est tout à fait bonne. Ajout de marqueurs, dessin Polygone excellent travail. Que diriez-vous de placer une seule image en superposition dans un endroit donné (latitude, longitude)? Cette fonctionalité manque je pense. Quelqu'un at-il fait placer la superposition d'image sans surcharger la source tuiles?

Était-ce utile?

La solution

J'ai trouvé la solution ...

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

le mvMap est quelque part IBOutlet RMMapView * mvMap dans votre fichier h

oSector.im_overlay.CGImage peut être

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

Autres conseils

Pourquoi ne pas simplement utiliser un RMMarker? Vous pouvez appliquer une image que vous voulez et placez-le au besoin. Même faire draggable si vous voulez:

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top