Skip to content

Commit

Permalink
Merge pull request #109 from hansemannn/master
Browse files Browse the repository at this point in the history
[TIMOB-19102] Resolve map crashes with vectors
  • Loading branch information
cheekiatng committed Jul 20, 2015
2 parents 7dfcfa0 + 74ec45d commit fbcc395
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 46 deletions.
110 changes: 65 additions & 45 deletions ios/Classes/TiMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -538,15 +538,19 @@ -(void)setLocation_:(id)location

-(void)addRoute:(TiMapRouteProxy*)route
{
CFDictionaryAddValue(mapObjects2View, [route routeLine], [route routeRenderer]);
[self addOverlay:[route routeLine] level:[route level]];
TiThreadPerformOnMainThread(^{
CFDictionaryAddValue(mapObjects2View, [route routeLine], [route routeRenderer]);
[self addOverlay:[route routeLine] level:[route level]];
}, NO);
}

-(void)removeRoute:(TiMapRouteProxy*)route
{
MKPolyline *routeLine = [route routeLine];
CFDictionaryRemoveValue(mapObjects2View, routeLine);
[map removeOverlay:routeLine];
TiThreadPerformOnMainThread(^{
MKPolyline *routeLine = [route routeLine];
CFDictionaryRemoveValue(mapObjects2View, routeLine);
[map removeOverlay:routeLine];
}, NO);
}

-(void)addPolygons:(NSMutableArray*)polygons
Expand All @@ -557,16 +561,18 @@ -(void)addPolygons:(NSMutableArray*)polygons
}
}


-(void)addPolygon:(TiMapPolygonProxy*)polygonProxy
{
MKPolygon *poly = [polygonProxy polygon];
CFDictionaryAddValue(mapObjects2View, poly, [polygonProxy polygonRenderer]);
[map addOverlay:poly];
if (polygonProxies == nil) {
polygonProxies = [[NSMutableArray alloc] init];
}
[polygonProxies addObject:polygonProxy];
TiThreadPerformOnMainThread(^{
MKPolygon *poly = [polygonProxy polygon];
CFDictionaryAddValue(mapObjects2View, poly, [polygonProxy polygonRenderer]);
[map addOverlay:poly];

if (polygonProxies == nil) {
polygonProxies = [[NSMutableArray alloc] init];
}
[polygonProxies addObject:polygonProxy];
}, NO);
}

-(void)removePolygon:(TiMapPolygonProxy*)polygonProxy
Expand All @@ -576,12 +582,14 @@ -(void)removePolygon:(TiMapPolygonProxy*)polygonProxy

-(void)removePolygon:(TiMapPolygonProxy*)polygonProxy remove:(BOOL)r
{
MKPolygon *poly = [polygonProxy polygon];
CFDictionaryRemoveValue(mapObjects2View, poly);
[map removeOverlay:poly];
if (r) {
[polygonProxies removeObject:polygonProxy];
}
TiThreadPerformOnMainThread(^{
MKPolygon *poly = [polygonProxy polygon];
CFDictionaryRemoveValue(mapObjects2View, poly);
[map removeOverlay:poly];
if (r) {
[polygonProxies removeObject:polygonProxy];
}
}, NO);
}

-(void)removeAllPolygons {
Expand All @@ -593,14 +601,19 @@ -(void)removeAllPolygons {
}

-(void)addCircle:(TiMapCircleProxy*)circleProxy {
MKCircle *circle = [circleProxy circle];
CFDictionaryAddValue(mapObjects2View, circle, [circleProxy circleRenderer]);
[map addOverlay:circle];
if (circleProxies == nil) {
circleProxies = [[NSMutableArray alloc] init];
}
[circleProxies addObject:circleProxy];

TiThreadPerformOnMainThread(^{
MKCircle *circle = [circleProxy circle];
CFDictionaryAddValue(mapObjects2View, circle, [circleProxy circleRenderer]);
[map addOverlay:circle];

if (circleProxies == nil) {
circleProxies = [[NSMutableArray alloc] init];
}
[circleProxies addObject:circleProxy];
}, NO);
}

-(void)addCircles:(NSMutableArray*)circles
{
for (TiMapCircleProxy *circle in circles)
Expand All @@ -616,13 +629,16 @@ -(void)removeCircle:(TiMapCircleProxy*)circleProxy

-(void)removeCircle:(TiMapCircleProxy*)circleProxy remove:(BOOL)r
{
MKCircle *circle = [circleProxy circle];
CFDictionaryRemoveValue(mapObjects2View, circle);
[map removeOverlay:circle];
if (r) {
[circleProxies removeObject:circleProxy];
}
TiThreadPerformOnMainThread(^{
MKCircle *circle = [circleProxy circle];
CFDictionaryRemoveValue(mapObjects2View, circle);
[map removeOverlay:circle];
if (r) {
[circleProxies removeObject:circleProxy];
}
}, NO);
}

-(void)removeAllCircles {
for (int i=0; i < [circleProxies count]; i++) {
TiMapCircleProxy *circle = [circleProxies objectAtIndex:i];
Expand All @@ -641,13 +657,15 @@ -(void)addPolylines:(NSMutableArray*)polylines

-(void)addPolyline:(TiMapPolylineProxy*)polylineProxy
{
MKPolyline *poly = [polylineProxy polyline];
CFDictionaryAddValue(mapObjects2View, poly, [polylineProxy polylineRenderer]);
[map addOverlay:poly];
if (polylineProxies == nil) {
polylineProxies = [[NSMutableArray alloc] init];
}
[polylineProxies addObject:polylineProxy];
TiThreadPerformOnMainThread(^{
MKPolyline *poly = [polylineProxy polyline];
CFDictionaryAddValue(mapObjects2View, poly, [polylineProxy polylineRenderer]);
[map addOverlay:poly];
if (polylineProxies == nil) {
polylineProxies = [[NSMutableArray alloc] init];
}
[polylineProxies addObject:polylineProxy];
}, NO);
}

-(void)removePolyline:(TiMapPolylineProxy*)polylineProxy
Expand All @@ -657,12 +675,14 @@ -(void)removePolyline:(TiMapPolylineProxy*)polylineProxy

-(void)removePolyline:(TiMapPolylineProxy*)polylineProxy remove:(BOOL)r
{
MKPolyline *poly = [polylineProxy polyline];
CFDictionaryRemoveValue(mapObjects2View, poly);
[map removeOverlay:poly];
if (r) {
[polylineProxies removeObject:polylineProxy];
}
TiThreadPerformOnMainThread(^{
MKPolyline *poly = [polylineProxy polyline];
CFDictionaryRemoveValue(mapObjects2View, poly);
[map removeOverlay:poly];
if (r) {
[polylineProxies removeObject:polylineProxy];
}
}, NO);
}

-(void)removeAllPolylines {
Expand Down
1 change: 1 addition & 0 deletions ios/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change Log
<pre>
v2.3.2 Fixed map crash with polygons when not setting mapType. [TIMOB-19102]
v2.3.1 Add drawing support. Includes polygons, polylines, and circles. [TIMOB-15410]
Fixes longclick event on iOS. [Github #41]
v2.2.2 Fixed map annotations showing undeclared buttons in iOS7 [TIMOB-17953]
Expand Down
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.3.1
version: 2.3.2
apiversion: 2
architectures: armv7 arm64 i386 x86_64
description: External version of Map module
Expand Down

0 comments on commit fbcc395

Please sign in to comment.