Select to view content in your preferred language

How do I create a layer that is generated from an image?

4761
12
Jump to solution
06-18-2012 11:56 PM
BillNalen
Emerging Contributor
I'm trying to add an overlay image to the map in iOS. The iOS MapKit allows me to specify an overlay image to use on top of the map and that's what version 1.0 of my app did. I've changed to use the ArcGIS maps and I want to add the same type of overlay.

I'm able to create the AGSMapView and add it to my view and everything works fine. I'm able to add a graphics layer and add some symbols with callouts just fine too.

I have the image retrieved from the server and I know the envelope of the affected area where I want to overlay the image. I'm just not sure how to add a given image to the map. I've tried:

- Create a custom tiled layer - but after reading a blog post on esri it seemed to indicate that images should use the dynamic layer

- Create a custom dynamic layer - I subclassed AGSDynamicLayer. My subclass returns the right envelope, spatial reference, units and initial envelope. I'm also defining exportMapImage but I don't know what should go in that method. I'm creating a subclass of NSOperation which implements AGSDynamicLayerDrawingOperation but it doesn't seem to do anything. I'm also calling [self.exportDelegate dynamicLayer:self exportMapImageOperation:operation didFinishWithImage:self.mapImage]; in exportMapImage. I can see my method get called and the image and parameters seem good. But no image shows on the map (I've added my custom dynamic layer to the AGSMapView).

- Create a new graphic layer - I created a graphics layer and added my image to it using AGSGraphic graphicWithGeometry:graphicRect symbol:graphicSymbol attributes:graphicAttributes infoTemplateDelegate:self]; where the graphicRect is bounds of my image envelope and the graphicSymbol is [AGSPictureMarkerSymbol pictureMarkerSymbolWithImage:mapImage]; - This does put my image on the map, but it's not scaling correctly when I zoom or move the map. I want it to remain in the specified rectangle even when the map is moved or zoomed.

I'm not sure what direction I should take, I feel like I'm not going about this the right way.

Here's an example of what I want to do:
- go to http://raidsonline.com/
- on the left, pick AZ - Avondale from the Jump To City dropdown
- on the left, check the box in front of density map under the Analytic Layers section.
- the image the shows up on the map is the image I'm retrieving from the server and want to add on top of the map on the iPhone/iPad
0 Kudos
12 Replies
SomnusLee
Emerging Contributor
Great! Glad to know that everything is working for you now! 🙂

Regards,
Nimesh



Hi, Nimesh and Bill

I have read this thread. And I think I encounter a similar problem: I also retrieve an image from server,and the server also returns an envelope of the image. Now I have to add this image to the map layer within the right envelope, and let the image scaled correctly when the map zoomed in or out, just keep the image in the constant envelope.

I also download the attachment you provided to resolve Bill's problem. However, I found that there are not these methods in AGSDynamicLayer of the latest iOS SDK.
For example, - (NSOperation<AGSDynamicLayerDrawingOperation>*)exportMapImage:(AGSExportImageParams*)params {...}
and now I find
- (void) requestImageWithWidth:(NSInteger) width height:(NSInteger) height envelope:(AGSEnvelope *) env timeExtent:(AGSTimeExtent *) timeExtent{...} instead.

How should I do now? I have been troubled with this problem for a long time, and can't find any solution.
Would you please help me? Thanks for any help you can give!

Best Regards
Somnus Lee
0 Kudos
NimeshJarecha
Esri Regular Contributor
The custom dynamic layer sample is available on github.

You should use AGSImageRequestOperation to request an image from requestImageWithWidth method.

Regards,
Nimesh
0 Kudos
SomnusLee
Emerging Contributor
The custom dynamic layer sample is available on github.

You should use AGSImageRequestOperation to request an image from requestImageWithWidth method.

Regards,
Nimesh


Wow, great! Thanks very much for your new year gift! Happy New Year To You!
0 Kudos