Authored by Justin R. Miller

fix bug & clarify that only points are supported currently

@@ -92,7 +92,7 @@ typedef enum : NSUInteger { @@ -92,7 +92,7 @@ typedef enum : NSUInteger {
92 * @return An initialized Mapbox tile source. */ 92 * @return An initialized Mapbox tile source. */
93 - (id)initWithTileJSON:(NSString *)tileJSON; 93 - (id)initWithTileJSON:(NSString *)tileJSON;
94 94
95 -/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. 95 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add point annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
96 * 96 *
97 * This method requires a network connection in order to download the TileJSON used to define the tile source. 97 * This method requires a network connection in order to download the TileJSON used to define the tile source.
98 * 98 *
@@ -101,7 +101,7 @@ typedef enum : NSUInteger { @@ -101,7 +101,7 @@ typedef enum : NSUInteger {
101 * @return An initialized Mapbox tile source. */ 101 * @return An initialized Mapbox tile source. */
102 - (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView; 102 - (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView;
103 103
104 -/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data, optionally enabling SSL. 104 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add point annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data, optionally enabling SSL.
105 * 105 *
106 * This method requires a network connection in order to download the TileJSON used to define the tile source. 106 * This method requires a network connection in order to download the TileJSON used to define the tile source.
107 * 107 *
@@ -111,13 +111,13 @@ typedef enum : NSUInteger { @@ -111,13 +111,13 @@ typedef enum : NSUInteger {
111 * @return An initialized Mapbox tile source. */ 111 * @return An initialized Mapbox tile source. */
112 - (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView enablingSSL:(BOOL)enableSSL; 112 - (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView enablingSSL:(BOOL)enableSSL;
113 113
114 -/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. 114 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add point annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
115 * @param tileJSON A string containing TileJSON. 115 * @param tileJSON A string containing TileJSON.
116 * @param mapView A map view on which to display the annotations. 116 * @param mapView A map view on which to display the annotations.
117 * @return An initialized Mapbox tile source. */ 117 * @return An initialized Mapbox tile source. */
118 - (id)initWithTileJSON:(NSString *)tileJSON enablingDataOnMapView:(RMMapView *)mapView; 118 - (id)initWithTileJSON:(NSString *)tileJSON enablingDataOnMapView:(RMMapView *)mapView;
119 119
120 -/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. 120 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add point annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
121 * 121 *
122 * Passing a remote URL requires a network connection. If offline functionality is desired, you should cache the TileJSON locally at a prior date, then pass a file path URL to this method. 122 * Passing a remote URL requires a network connection. If offline functionality is desired, you should cache the TileJSON locally at a prior date, then pass a file path URL to this method.
123 * 123 *
@@ -116,26 +116,29 @@ @@ -116,26 +116,29 @@
116 { 116 {
117 for (NSDictionary *feature in jsonObject[@"features"]) 117 for (NSDictionary *feature in jsonObject[@"features"])
118 { 118 {
119 - NSDictionary *properties = feature[@"properties"];  
120 -  
121 - CLLocationCoordinate2D coordinate = {  
122 - .longitude = [feature[@"geometry"][@"coordinates"][0] floatValue],  
123 - .latitude = [feature[@"geometry"][@"coordinates"][1] floatValue]  
124 - };  
125 -  
126 - RMAnnotation *annotation = nil;  
127 -  
128 - if ([mapView.delegate respondsToSelector:@selector(mapView:layerForAnnotation:)])  
129 - annotation = [RMAnnotation annotationWithMapView:mapView coordinate:coordinate andTitle:properties[@"title"]];  
130 - else  
131 - annotation = [RMPointAnnotation annotationWithMapView:mapView coordinate:coordinate andTitle:properties[@"title"]];  
132 -  
133 - annotation.userInfo = properties;  
134 -  
135 - dispatch_async(dispatch_get_main_queue(), ^(void) 119 + if ([feature[@"geometry"][@"type"] isEqualToString:@"Point"])
136 { 120 {
137 - [mapView addAnnotation:annotation];  
138 - }); 121 + NSDictionary *properties = feature[@"properties"];
  122 +
  123 + CLLocationCoordinate2D coordinate = {
  124 + .longitude = [feature[@"geometry"][@"coordinates"][0] floatValue],
  125 + .latitude = [feature[@"geometry"][@"coordinates"][1] floatValue]
  126 + };
  127 +
  128 + RMAnnotation *annotation = nil;
  129 +
  130 + if ([mapView.delegate respondsToSelector:@selector(mapView:layerForAnnotation:)])
  131 + annotation = [RMAnnotation annotationWithMapView:mapView coordinate:coordinate andTitle:properties[@"title"]];
  132 + else
  133 + annotation = [RMPointAnnotation annotationWithMapView:mapView coordinate:coordinate andTitle:properties[@"title"]];
  134 +
  135 + annotation.userInfo = properties;
  136 +
  137 + dispatch_async(dispatch_get_main_queue(), ^(void)
  138 + {
  139 + [mapView addAnnotation:annotation];
  140 + });
  141 + }
139 } 142 }
140 } 143 }
141 } 144 }