Problem with displaying an image in an AGSPopupInfo?

271
6
Jump to solution
02-22-2012 05:24 PM
c_f_ong
New Contributor III
Hello

I'm having a problem with the code below to display an image in an AGSPopupInfo. Any idea what may be the cause? Any example?

   AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:mapUrl, @"sourceURL", nil];
    AGSPopupMediaInfo *mediaInfo = [[AGSPopupMediaInfo alloc] initWithTitle:@"Title" caption:@"Caption" type:AGSPopupMediaInfoTypeImage value:dict];
    info.mediaInfos = [NSArray arrayWithObject:mediaInfo];
    self.popupVC = [[AGSPopupsContainerViewController alloc] initWithPopupInfo:info graphic:graphic usingNavigationControllerStack:NO];

Also, is there any way to use the AGSAttachmentManager with an AGSGraphicsLayer instead of an AGSFeatureLayer?

Thanks.

Rgds
Ong CF
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Here is the modified code of yours to show and image url..

NSString *imageUrl = @"http://upload.wikimedia.org/wikipedia/en/1/1e/New-esri-logo.gif";
AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:imageUrl, @"sourceURL", nil];
AGSPopupMediaInfo *mediaInfo = [[AGSPopupMediaInfo alloc] initWithTitle:@"Title" caption:@"Caption" type:AGSPopupMediaInfoTypeImage value:dict];
info.mediaInfos = [NSArray arrayWithObject:mediaInfo];
self.popupVC = [[AGSPopupsContainerViewController alloc] initWithPopupInfo:info graphic:graphic usingNavigationControllerStack:NO];

Regards,
Nimesh

View solution in original post

0 Kudos
6 Replies
NimeshJarecha
Esri Regular Contributor
Is mapUrl a URL string pointing to an image? If yes, it should work.

You can't use AGSAttachmentManager with AGSGraphicsLayer.

Regards,
Nimesh
0 Kudos
c_f_ong
New Contributor III
Hello

As I can't use AGSAttachmentManager with AGSGraphicsLayer, that's why I'm fiddling with how to show an image in AGSPopupInfo. Thanks for pointing out the problem.

How to set mapUrl to a URL string pointing to an image on the simulator/device? Any example?

I'm trying to make it work without getting the image from an AGSFeatureLayer on the server.

Thanks.

Rgds
Ong CF
0 Kudos
NimeshJarecha
Esri Regular Contributor
Here is the modified code of yours to show and image url..

NSString *imageUrl = @"http://upload.wikimedia.org/wikipedia/en/1/1e/New-esri-logo.gif";
AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:imageUrl, @"sourceURL", nil];
AGSPopupMediaInfo *mediaInfo = [[AGSPopupMediaInfo alloc] initWithTitle:@"Title" caption:@"Caption" type:AGSPopupMediaInfoTypeImage value:dict];
info.mediaInfos = [NSArray arrayWithObject:mediaInfo];
self.popupVC = [[AGSPopupsContainerViewController alloc] initWithPopupInfo:info graphic:graphic usingNavigationControllerStack:NO];

Regards,
Nimesh

View solution in original post

0 Kudos
c_f_ong
New Contributor III
Hello

Thanks for your quick response. Hope you don't mind to also show an example of how to set the URL to an image that's stored on the iPad such as from the camera roll.

Rgds
Ong CF
0 Kudos
NimeshJarecha
Esri Regular Contributor
You should try to find the iOS SDK help, how to get the URL of a photo in camera roll or library.

Regards,
Nimesh
0 Kudos
c_f_ong
New Contributor III
Hi Nimesh

Thanks for your help! Will search documentation for the how...

Rgds
Ong CF
0 Kudos