POST
|
It turns out I needed to add a filler symbol. I was also needlessly converting back and forth between projections and I forgot to mention part of my code in my post. Here's the new code: AGSPoint* centerPoint = [AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]]; AGSPolygon *polygon = [self circleWithCenter:webMercatorPoint radius:rangeInMeters]; AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:polygon symbol:[AGSSimpleFillSymbol simpleFillSymbol] attributes:nil]; [self.markerGraphicsLayer addGraphic:graphic]; -(AGSPolygon*) circleWithCenter:(AGSPoint*)point radius:(double)radiusInMeters { AGSGeometryEngine *ge = [AGSGeometryEngine defaultGeometryEngine]; AGSPoint *pointToBufferAround = (AGSPoint *)[ge projectGeometry:point toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]]; AGSPolygon *circle = [ge bufferGeometry:pointToBufferAround byDistance:radiusInMeters]; return circle; }
... View more
06-12-2014
11:23 PM
|
0
|
0
|
365
|
POST
|
I built a feature which searches documents within a certain range (in meters) around a coordinate. I would like to show this range to the user by drawing a circle. I think I go the individual pieces, through e.g. this post, but I can't fit them together. graphicsLayer is an instance of ASGraphicsLayer, which is already displaying a bunch of items. latitude and longitude are in decimal degrees. The graphics layer is in web mercator. AGSPoint* centerPoint = [AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]]; AGSPoint *webMercatorPoint = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:centerPoint toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]]; AGSPolygon *polygon = [self circleWithCenter:webMercatorPoint radius:rangeInMeters]; AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:polygon symbol:nil attributes:nil]; [self.markerGraphicsLayer addGraphic:graphic]; I don't see a circle on the map when I do this.
... View more
06-12-2014
07:18 AM
|
0
|
1
|
1560
|
POST
|
Thanks! That should help me get started. Is there a guide for when I want to do more advanced stuff with a AGSDynamicLayer subclass? For example the layer would contain multiple images for different locations, the images might overlap, the images need to be rotated and perhaps it makes sense to adjust their resolution based on the zoom level. For now I just need to make a proof of concept with a single image, so I can do that with the example in Github you pointed me to.
... View more
05-12-2014
09:53 AM
|
0
|
0
|
537
|
POST
|
I have an image which I would like to project on a map at a certain coordinate, scale and rotation. For example the image might by 1000 by 1000 pixels and represent an area the size of 0.01x0.05 decimal degrees, oriented north to keep things simple. It's transparant so I want to see the base map below it. I tried using a AGSPictureMarkerSymbol but it displays the image with a fixed number of pixels, regardless of zoom level. So it would look as big as the earth or as small as a house, rather than a fixed 0.01x0.05 decimal degrees. AGSPictureMarkerSymbol *symbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"SomeObject"]; double lat = 55.0; double lon = 5.0 AGSMutablePolygon *area = [[AGSMutablePolygon alloc] initWithSpatialReference:[AGSSpatialReference wgs84SpatialReference] ]; [area addRingToPolygon]; [area addPointToRing:[AGSPoint pointWithX:lon y:lat spatialReference:nil]]; [area addPointToRing:[AGSPoint pointWithX:lon + 0.01 y:lat spatialReference:nil]]; [area addPointToRing:[AGSPoint pointWithX:lon+0.01 y:lat + 0.005 spatialReference:nil]]; [area addPointToRing:[AGSPoint pointWithX:lon y:lat + 0.005 spatialReference:nil]]; [area closePolygon]; AGSPoint *webMercatorArea = (AGSPoint *)[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:area toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]]; AGSGraphic *previewGraphic = [AGSGraphic graphicWithGeometry:webMercatorArea symbol:symbol attributes:nil]; [self.documentGraphicsLayer addGraphic:graphic]; I also tried using AGSPictureFillSymbol. This at least prevents the image from drawing outside the specified area on the map, but the scale is still wrong. AGSPictureFillSymbol *symbol = [AGSPictureFillSymbol pictureFillSymbolWithImageNamed:@"SomeObject"]; I'm probably using the wrong approach here.
... View more
05-12-2014
06:49 AM
|
0
|
2
|
1501
|
POST
|
Thanks! I just had to set the spatial reference of the envelope to [AGSSpatialReference wgs84SpatialReference] (decimal coordinates) and the map automagically converts that to its own spatial reference and zooms in on the correct location.
AGSEnvelope *envelope = [AGSEnvelope envelopeWithXmin:x - zoomDegrees ymin:y - zoomDegrees xmax:x + zoomDegrees ymax:y + zoomDegrees
spatialReference:[AGSSpatialReference wgs84SpatialReference]];
... View more
04-28-2014
12:39 AM
|
0
|
0
|
278
|
POST
|
I'm showing a small map in an iPad app and I'm able to display the user location on it as a blinking blue dot on a map of the world. I would like to zoom in on a specific location, e.g. the city of Utrecht in The Netherlands, at a zoom level of a few hundred meters. Unfortunately when I call zoomToEnvelope:envelope it drops me in the middle of the ocean, presumably 0 latitude by 0 longitude. If on the other hand I call zoomWithFactor the app doesn't zoom in anywhere. I must be doing something wrong. I actually had it working before, so perhaps I broke something (I'll try diff-ing my way to fixing it). The spatial reference of AGSMapView *map is as excepted when mapViewDidLoad is called. I'm not getting any error messages. I'm calling zoomToEnvelope on the main thread. What else should be careful about? // ViewController.m #import <ArcGIS/ArcGIS.h> @interface ViewController () <AGSMapViewLayerDelegate> { IBOutlet AGSMapView *map; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSString *mapLocation = @"https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"; AGSTiledMapServiceLayer *basemapServiceLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:mapLocation]]; [map addMapLayer:basemapServiceLayer withName:@"Tiled Layer"]; map.layerDelegate = self; } -(void)mapViewDidLoad:(AGSMapView *)mapView { [map.locationDisplay startDataSource]; if(map.loaded) { double x = 5.0; double y = 52.5; zoomDegrees = 0.005 AGSEnvelope *envelope = [AGSEnvelope envelopeWithXmin:x - zoomDegrees ymin:y - zoomDegrees xmax:x + zoomDegrees ymax:y + zoomDegrees spatialReference:map.spatialReference]; // Zooms in on the equator: [map zoomToEnvelope:envelope animated:YES]; // Does nothing at all: // [map zoomWithFactor:4 atAnchorPoint:CGPointMake(50, 80) animated:YES]; } } @end
... View more
04-25-2014
07:37 AM
|
0
|
2
|
2463
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|