In my subclass init method I do this, where heatArea is the visible area of the map translated to WKID 4326 (which I pass to the server to retrieve the image) (my base map is in WKID 102100)
AGSSpatialReference *baseSR = [AGSSpatialReference spatialReferenceWithWKID:102100];
AGSGeometryEngine *geometryEngine = [AGSGeometryEngine defaultGeometryEngine];
AGSPoint *min = [[AGSPoint alloc] initWithX:heatArea.envelope.xmin y:heatArea.envelope.ymin spatialReference:heatArea.envelope.spatialReference];
AGSPoint *adjustedMin = (AGSPoint*) [geometryEngine projectGeometry:min toSpatialReference:baseSR];
AGSPoint *max = [[AGSPoint alloc] initWithX:heatArea.envelope.xmax y:heatArea.envelope.ymax spatialReference:heatArea.envelope.spatialReference];
AGSPoint *adjustedMax = (AGSPoint*) [geometryEngine projectGeometry:max toSpatialReference:baseSR];
densityFullEnvelope = [AGSEnvelope envelopeWithXmin:adjustedMin.x
ymin:adjustedMin.y
xmax:adjustedMax.x
ymax:adjustedMax.y
spatialReference:baseSR];
I then override these methods (though only the first one ever seems to be called):
- (NSOperation<AGSDynamicLayerDrawingOperation>*)exportMapImage:(AGSExportImageParams*)params
{
DensityMapOperation *operation = [[DensityMapOperation alloc] initWithParams:params];
[self.exportDelegate dynamicLayer:self exportMapImageOperation:operation didFinishWithImage:self.mapImage];
return operation;
}
- (AGSUnits)units
{
return densityUnits;
}
- (AGSSpatialReference *)spatialReference
{
return densityFullEnvelope.spatialReference;
}
- (AGSEnvelope *)fullEnvelope
{
return densityFullEnvelope;
}
- (AGSEnvelope *)initialEnvelope
{
//Assuming our initial extent is the same as the full extent
return densityFullEnvelope;
}
I didn't find anything in the documentation about what to override in my subclass of NSOperation <AGSDynamicLayerDrawingOperation> so I just overrode the following which are the parameters originally passed in when the object was created:
- (AGSExportImageParams *)exportImageParams
{
return theParams;
}
It seems like the following line is the only thing that has an image in it:
[self.exportDelegate dynamicLayer:self exportMapImageOperation:operation didFinishWithImage:self.mapImage];
But why would I pass the image and the operation to the delegate? That seems a little confusing. I was expecting to pass the image to some view that would then use it and draw it on the screen. Finally, I'm adding the layer like this:
DensityMapLayer *densityMapLayer = [[DensityMapLayer alloc] initWithGeometry:heatArea];
densityMapLayer.mapImage = [heatServer.mapImage copy];
UIView *densityView = [self.mapView addMapLayer:densityMapLayer withName:@"Density Layer"];
Nothing shows on the map even though the image is good (I can throw the image in a UIImageView and it shows properly). I also can't find where the operation created in the method above gets used. It doesn't seem to run or anything, just one property seems to get hit. I was hoping to see something like MapImageLayer from the Javascript library where I could just pass the layer an image and add it to the map.Hopefully I'm missing something here. I did look through a ton of documentation and the header files, but I didn't see any other methods on AGSDynamicLayer or NSOperation <AGSDynamicLayerDrawingOperation> that would help me.thanks for any help you can give.