A category on UIImageView
to turn it into a North Arrow for the ArcGIS Runtime SDK for iOS.
- Drag the
UIImageView+AGSNorthArrow.h
andUIImageView+AGSNorthArrow.m
files into your ArcGIS Runtime for iOS project in Xcode. - Reference the category in your code (
#import
theUIImageView+AGSNorthArrow.h
file).
- Add a
UIImageView
to your user interface. Make sure it does not become a child of yourAGSMapView
(although it can overlap it). - Ensure this
UIImageView
is referenced from your code. - Set the
mapViewForNorthArrow
property on theUIImageView
to theAGSMapView
it represents. - Set the Image on the
UIImageView
(see samples provided in this repo).
Here's a sample ViewController.m:
#import <ArcGIS/ArcGIS.h>
#import "UIImageView+AGSNorthArrow.h"
@interface AGSNorthArrowSampleViewController ()
@property (weak, nonatomic) IBOutlet AGSMapView *mapView;
@property (weak, nonatomic) IBOutlet UIImageView *northArrow;
@end
@implementation AGSNorthArrowSampleViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *basemapURL = [NSURL URLWithString:@"http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"];
AGSTiledMapServiceLayer *basemapLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:basemapURL];
[self.mapView addMapLayer:basemapLayer];
self.mapView.allowRotationByPinching = YES;
self.northArrow.mapViewForNorthArrow = self.mapView;
}
@end
In the above code, the UIImageView
is configured in the Storyboard:
Also see the included [example Xcode](Demo Project) project.
At runtime, the following properties will be set automatically on the UIImageView
control:
View Mode
is set toAspect Fit
User Interaction
is disabled
This code has been tested against the 10.2 release of the ArcGIS Runtime SDK for iOS. While it should work with the 10.1 release onwards and may work with earlier releases, it has not been tested against them.
- ArcGIS Runtime SDK for iOS
- ArcGIS Runtime SDK Forums
- ArcGIS Blog
- Twitter @esri
- Apple iOS Dev Center
- North Arrow Clipart
- Pointing Finger Clipart
Find a bug or want to request a new feature? Please let us know by submitting an Issue.
Anyone and everyone is welcome to contribute.
Copyright 2014 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository's license.txt file. [](Esri Tags: NorthArrow ArcGIS Mobile Mapping iOS iPhone iPad) [](Esri Language: Objective-C)