0

I used an UIImage to initialize an MGLImageSource. Then I use the MGLImageSource to initialize a MGLRasterStyleLayer and I add the layer to a MGLMapView. It turned out that the image is too big to fit entirely into the map view. How do I tell MGLMapview to scale an image automatically so that the image fits entirely into the view like the 'scale to fit' in iOS ? thanks !

Here is how I add the image into the map view:

UIImage *radarImage = [UIImage imageNamed:@"radar.png"];
    MGLImageSource *source = [[MGLImageSource alloc] initWithIdentifier:@"radar" coordinateQuad:coordinates image:radarImage];
    [style addSource:source];
   
MGLRasterStyleLayer *radarLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"radar-layer" source:source];
[style addLayer: radarLayer];
Hiren Dhamecha
  • 658
  • 5
  • 15
yuleo
  • 1

1 Answers1

0

set a property of mapview called visibleCoordinates; it has two members SW and NE which stands for the top right corner and low left corner of the visible view. That will restrict the size of the image and automatically resize the image.

yuleo
  • 1