POST
|
Forgot to include in my comments: I'm looping through a dictionary while executing the above code.... (I'm adding a couple of graphics to the layer)
... View more
04-17-2012
12:38 PM
|
0
|
0
|
471
|
POST
|
I've added the following to my header file: LocationInfoTemplate *_locationInfoTemplate; @property (nonatomic, retain) LocationInfoTemplate * locationInfoTemplate; But it still fails. I miss the old-skool Retain command, but i can't use it when using ARC.. 😞
... View more
04-17-2012
12:21 PM
|
0
|
0
|
471
|
POST
|
Hi all, I'm adding some graphics manually to the map, with the following code:
double lat = [(NSNumber *) [colleague objectForKey: @"Latitude"] doubleValue];
double lon = [(NSNumber *) [colleague objectForKey: @"Longitude"] doubleValue];
if ( !(lat == 0.00 && lon == 0.00))
{
AGSSimpleMarkerSymbol *pointMarker = [AGSSimpleMarkerSymbol simpleMarkerSymbolWithColor:[UIColor orangeColor]];
pointMarker.size = 15; //[(NSNumber *) [colleague objectForKey: @"Precision"] intValue];
pointMarker.style = AGSSimpleMarkerSymbolStyleCircle;
AGSPoint *wgspoint = [AGSPoint pointWithX:lon y:lat spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]];
AGSGeometry *mapPoint = [_geometryEngine projectGeometry:wgspoint toSpatialReference:self.mapView.spatialReference];
// LocationInfoTemplate * template = [[LocationInfoTemplate alloc] init];
AGSCalloutTemplate* template = [[AGSCalloutTemplate alloc] init] ;
template.titleTemplate = @"${Username}";
template.detailTemplate = @"${TimeStamp}";
AGSGraphic *location = [[AGSGraphic alloc] initWithGeometry: mapPoint
symbol: pointMarker
attributes: [colleague mutableCopy]
infoTemplateDelegate: template]; //template];
[_trackLayer addGraphic:location];
//template = Nil;
}
I've got the following issue. When the user taps on the graphic, the callout is supposed to be shown. But the application crashes in some SDK assembly, to be specific: 0x0011bed8 <+0052> tst.w r0, #255 ; 0xff in the [AGSMapView setupCalloutUiForGraphic:mapPoint] I've tried to use my own TemplateClass (LocationInfoTemplate) and the AGSCalloutTemplate class, both had the same result. To debug this, i've added the following function: - (BOOL)mapView:(AGSMapView *)mapView shouldShowCalloutForGraphic:(AGSGraphic *)graphic {
NSLog(@"Click");
return true;
}
Just to see what's in the Graphic object. And i was surprised: First run: _infoTemplateDelegate UIImage * 0xde9ad50 Second run: _infoTemplateDelegate __NSCFNumber * 0xde9acd0 I think i can say that the infoTemplate is NOT retained! What's the problem here? I'm using the 2.1 SDK, i'm using the latest Xcode (With ARC) and the latest iOS.... --Edit-- Updated tot 2.2.1 SDK, same behavior.
... View more
04-17-2012
06:35 AM
|
0
|
9
|
1098
|
POST
|
Hi all, I retrieve some data from a webserver, through JSON. This works flawless. In this data is the latitude, longitude and a name. I want to add this data to my mapview, i've added a AGSGraphicsLayer to do this. I add the graphics layer with the following code:
self.trackLayer = [AGSGraphicsLayer graphicsLayer];
[self.mapView addMapLayer:self.trackLayer withName:@"trackLayer"];
This works. As expected. When i push a button the data is received, and added to the map:
NSArray *locations = [_locationService getLocations];
for (NSDictionary* loc in locations) {
NSLog(@"%@", loc);
float lat = [[loc objectForKey:@"lat"] floatValue];
float lon = [[loc objectForKey:@"lon"] floatValue];
AGSSimpleMarkerSymbol *pointMarker = [AGSSimpleMarkerSymbol simpleMarkerSymbolWithColor:[UIColor redColor]];
pointMarker.size = 10.00;
pointMarker.style = AGSSimpleMarkerSymbolStyleCircle;
AGSPoint *point = [AGSPoint pointWithX:lat y:lon spatialReference:self.mapView.spatialReference];
AGSGraphic *location = [[AGSGraphic alloc] initWithGeometry:point symbol:pointMarker attributes:Nil infoTemplateDelegate:Nil];
NSLog(@"%@", location);
[_trackLayer addGraphic:location];
}
[_trackLayer dataChanged];
The NSLog produces the following: geometry: AGSPoint: x = 52.322800, y = 4.879720, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null], symbol: { AGSSimpleMarkerSymbol: style: esriSMSCircle, size: 10.000000, outline: <AGSSimpleLineSymbol: 0x8c0b50> }, attributes: (null) When i print the description of the geometry within the Graphics layer: AGSPoint: x = 52.317799, y = 4.879200, spatial reference: [AGSSpatialReference: wkid = 102100, wkt = null] So, the coordinates are in the point. For all the testdata. But they are still shown at 0,0! Whats wrong here? The only thing i saw was that the renderer and initialEnvelope of the GraphicsLayer is 0x0... Many thanks!
... View more
09-20-2011
05:39 AM
|
0
|
2
|
485
|
POST
|
What do you mean by this, the authentication problem (The disappearing credentials) or the failure with the "#" in the password, or both? 😛
... View more
07-28-2011
11:27 PM
|
0
|
0
|
395
|
POST
|
Rene, 1. Which version of the API are you using? v1.8 or v2.0? 2. Is HTTP authentication Basic or Digest? 3. Is SSL enabled on the server? Regards, Nimesh 1. v1.8, we don't want to migrate to v2.0 in this stadium (Deadline coming up) 2. I asked the dude which manages the server side: Both, including Windows Authentication 3. SSL is NOT enabled. (Internal Server)
... View more
07-28-2011
12:22 AM
|
0
|
0
|
395
|
POST
|
Changed the code a bit, this seems to work flawless: NSURL* layerUrl = [((AGSDynamicMapServiceLayer*)layer).URL copy];
//Get the service info
NSError* error = nil;
AGSCredential* cred = [[AGSCredential alloc] initWithUser:((AGSDynamicMapServiceLayer*)layer).credential.username password:((AGSDynamicMapServiceLayer*)layer).credential.password authenticationType:[AGSCredential isServiceSecured:layerUrl]];
msi = [[AGSMapServiceInfo alloc] initWithURL:layerUrl credential:cred error:&error];
if (error)
NSLog(@"Error encountered while fetching legend : %@",error);
if(msi.version>=10.01){
msi.delegate = self;
[msi retrieveLegendInfo];
}else {
NSLog(@"Skipping layer [%@]. ArcGIS Service must be version 10 SP1 or above",msi.URL );
}
[layerUrl release];
[cred release]; Note: This is only for the dynamic layer. Since we dont use feature or tiled layers, we didn't implement the legend for these types of layers. But still, is this wanted behaviour? I would rather have that the ((AGSDynamicMapServiceLayer*)layer).mapserviceinfo (The MSI from the loaded layer) contains the credentials.. And than there is the password problem (#, /, \ in passwords result in non-loadable MapServiceInfo's)
... View more
07-27-2011
01:44 AM
|
0
|
0
|
395
|
POST
|
Hi, We were using the legend example from the website (http://www.arcgis.com/home/item.html?id=901ca5cbcc6e4fe9bee960136c5971ba) This worked like a charm, but when we enabled the authentication on the mapserver (HTTP authentication), it stopped working. Why? In the statement AGSMapServiceInfo* msi = ((AGSDynamicMapServiceLayer*)layer).mapServiceInfo; is the MapServiceInfo allocated, but there are no credentials available! These are not copied from the layer itself, nor is done when the DynamicMapServiceLayer from the mapview is used to retrieve the MapServiceInfo. Is this wanted? Because it is NOT possible to set the credentials, without recreating the whole object... The quick and dirty fix i've used now is: AGSMapServiceInfo* msi = [[AGSMapServiceInfo alloc] initWithURL:self.mapView.dynamicLayer.URL credential:self.mapView.dynamicLayer.credential error:&error]; This works, because there is only one dynamic layer, and only one layer (the dynamic layer) which uses the legend. It's still work in progress, but this is the code as used: NSError* error = nil;
AGSMapServiceInfo* msi;
if (((AGSDynamicMapServiceLayer*)layer).credential.authType == AGSAuthenticationTypeNone){
msi = ((AGSDynamicMapServiceLayer*)layer).mapServiceInfo;
} else {
msi = [[[AGSMapServiceInfo alloc] initWithURL:self.mapView.dynamicLayer.URL credential:self.mapView.dynamicLayer.credential error:&error] autorelease];
}
if (error)
NSLog(@"Error encountered while fetching legend : %@",error);
if(msi.version>=10.01){
msi.delegate = self;
[msi retrieveLegendInfo];
}else {
NSLog(@"Skipping layer [%@]. ArcGIS Service must be version 10 SP1 or above",msi.URL );
}
But, it didn't work in the beginning as expected. The application gave JSON paring errors, which didn't make sense. After a lot of research, we've found the reason: There was an "#" in the password. The legend is retrieved through http://user:password@url/MapServer/layers?f=json Because of the # the application couldn't find the used mapserver. I guess the same is applicable for the "/" or "\", and maybe even "&" The strange part is: With the same authentication, the mapserver itself (The map data) can be loaded... I guess this last one is a bug... It's rather dirty anyway to put the credentials in an url.. Anyway, i really want to know if my findings are correct, and if it's a bug, or something else. Many Thanks
... View more
07-26-2011
06:44 AM
|
0
|
6
|
2218
|
POST
|
Thanks. It works with this work-around. We want to cache this data, so these actions are necessary.
... View more
07-26-2011
03:47 AM
|
0
|
0
|
268
|
POST
|
Hi, I'm using an identifylayer, with the controller. The identify itself works, the object is highlighted with a color, but... I have to tap the object twice before the callout is shown. So, summarized: First tap: Object is selected (Highlighted) Second tap: Callout is shown I want to skip the second step, but i have no idea how. I looked into the class reference, but... couldn't find anything... The code I use: - (void)mapView:(AGSMapView *)mapView didClickAtPoint:(CGPoint)screen mapPoint:(AGSPoint *)mappoint graphics:(NSDictionary *)graphics {
self.identifyParams.tolerance = 7;
self.identifyParams.geometry = mappoint;
self.identifyParams.size = mapViewController.mapView.bounds.size;
self.identifyParams.mapEnvelope = mapViewController.mapView.envelope;
self.identifyParams.returnGeometry = YES;
self.identifyParams.layerOption = AGSIdentifyParametersLayerOptionAll;
self.identifyParams.spatialReference = mapViewController.mapView.spatialReference;
//execute the task
[self.identifyTask executeWithParameters:self.identifyParams];
}
//results are returned
- (void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results {
//clear previous results
[mapViewController.identifyLayer removeAllGraphics];
_identifyInfoTemplate = [[IdentifyInfoTemplate alloc] init];
for (AGSIdentifyResult* result in results) {
result.feature.symbol = [self determineAndReturnSymbol:AGSGeometryTypeForGeometry(result.feature.geometry)];
result.feature.infoTemplateDelegate = _identifyInfoTemplate;
[mapViewController.identifyLayer addGraphic:result.feature];
}
//call dataChanged on the graphics layer to redraw the graphics
[mapViewController.identifyLayer dataChanged];
}
... View more
06-09-2011
02:18 AM
|
0
|
1
|
366
|
POST
|
Of course. First, i check if the visiblelayer array is initialised. This is done in a synchronized code block, just to be sure. if (self.dynamicLayer.visibleLayers == nil){
NSLog(@"VisibleLayer is nil, initializing it.");
NSMutableArray *visLayers = [[NSMutableArray alloc]init];
for (AGSMapServiceLayerInfo* layer in self.dynamicLayer.mapServiceInfo.layerInfos){
if (layer.parentLayerID != -1){
if (layer.defaultVisibility ){
[visLayers addObject:[NSNumber numberWithUnsignedInt:layer.layerId]];
}
}
}
self.dynamicLayer.visibleLayers = [visLayers mutableCopy];
[visLayers autorelease];
}
} No problems there. Next, when i want to change the visibillity of the layers, i use the following function: - (void) setLayerVisibillity:(NSNumber *)layerId :(Boolean)visibillity
{
NSMutableArray *visibleLayers = [self.dynamicLayer.visibleLayers mutableCopy];
if (visibillity && ![visibleLayers containsObject:layerId]){
[visibleLayers addObject:layerId];
} else {
[visibleLayers removeObject:layerId];
}
self.dynamicLayer.visibleLayers = [visibleLayers mutableCopy];
[visibleLayers release];
//Doesn't work...
//[self.dynamicLayer dataChanged];
//WorkAround, without the ZoomToEnvelope the layer visibillity doesnt change.
[self.mapView zoomToEnvelope:self.mapView.envelope animated:true];
} The ZoomToEnvelope works like a charm, but it is a extra call. DOwnside, it reloads the data from the server, which is not nice if you are working over celluar data.. More details: IOS 4.3.3 iPad2 3G
... View more
06-09-2011
02:06 AM
|
0
|
0
|
268
|
POST
|
Hi, I'm using a dynamiclayer with a bunch of sublayers. When i change the visibillity of the sublayers (through the self.dynamicLayer.visibleLayers variable) the mapview (and thereby the dynamiclayer) doesnt change. The selected or deselected objects arent (dis)appearing, not even when the dynamiclayer datachanged method is called. Only when the map is moved the data changed (due reload of the data)... Is this wanted behaviour? It's kinda annoying that it doesnt change on the datachanged call... For now i implemented a work-around: [self.mapView zoomToEnvelope:self.mapView.envelope animated:true];
Many thanks.
... View more
06-06-2011
01:39 AM
|
0
|
4
|
911
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|