From ce53cc58877979edb326fe15aefff20cf0ca1a11 Mon Sep 17 00:00:00 2001 From: Ash Furrow Date: Tue, 17 Jun 2014 22:20:44 +0200 Subject: [PATCH] Fixed #37. --- CHANGELOG.md | 4 ++++ NAMapKit/NAMapView.m | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 498dd12..7c87f28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Next + +* [#37](https://github.com/neilang/NAMapKit/issues/37) - Fix `NAMapView` from returning `{NaN, NaN}` - [@ashfurrow](http://github.com/ashfurrow). + #### [3.1.1](https://github.com/neilang/NAMapKit/tree/v3.1.1) (5/12/2014) * [#31](https://github.com/neilang/NAMapKit/issues/31) - Fix: `NAPinAnnotation` and `NAPinAnnotationView` retain cycle - [@dblock](https://github.com/dblock). diff --git a/NAMapKit/NAMapView.m b/NAMapKit/NAMapView.m index a31feed..27a5849 100644 --- a/NAMapKit/NAMapView.m +++ b/NAMapKit/NAMapView.m @@ -121,9 +121,16 @@ - (void)centerOnPoint:(CGPoint)point animated:(BOOL)animate - (CGPoint)zoomRelativePoint:(CGPoint)point { - CGFloat x = (self.contentSize.width / self.originalSize.width) * point.x; - CGFloat y = (self.contentSize.height / self.originalSize.height) * point.y; - return CGPointMake(round(x), round(y)); + BOOL hasContentSize = fabsf(self.originalSize.width) > 0 && fabsf(self.originalSize.height) > 0; + NSAssert(hasContentSize, @"originalSize dimension is zero, will result in NaN in returned value."); + + if (hasContentSize) { + CGFloat x = (self.contentSize.width / self.originalSize.width) * point.x; + CGFloat y = (self.contentSize.height / self.originalSize.height) * point.y; + return CGPointMake(round(x), round(y)); + } else { + return CGPointZero; + } } - (void)selectAnnotation:(NAAnnotation *)annotation animated:(BOOL)animate