         })
         
     }
+    
+    func selectOnMap(geoBaseEntity : GeoBaseEntity){
+        if  highlightedLine != nil {
+            mapView.removeOverlay(highlightedLine);
+        }
+        var mapObj=geoBaseEntity.mapObject
+        
+        if mapObj is GeoBaseEntityPointAnnotation {
+            mapView.selectAnnotation(mapObj as MKAnnotation, animated: true);
+            //println("\((mapObj as GeoBaseEntityPointAnnotation).coordinate.latitude),\((mapObj as GeoBaseEntityPointAnnotation).coordinate.longitude)")
+        }
+        else if mapObj is GeoBaseEntityStyledMkPolylineAnnotation {
+            var line = mapObj as GeoBaseEntityStyledMkPolylineAnnotation;
+            highlightedLine = HighlightedMkPolyline(points: line.points(), count: line.pointCount);
+            mapView.removeOverlay(line);
+            mapView.addOverlay(highlightedLine);
+            mapView.addOverlay(line);
+            
+        }
+    }
+    
+    
+
+    @IBAction func mapTabbed(sender: UITapGestureRecognizer) {
+        let touchPt = sender.locationInView(mapView)
+        let coord = mapView.convertPoint(touchPt, toCoordinateFromView: mapView)
+        var nearestDistance: Double = -1.0
+        var nearestPolyline: GeoBaseEntityStyledMkPolylineAnnotation?
+        
+//        println("tabbed point:\(touchPt)")
+//        println("tabbed coord:\(coord.latitude),\(coord.longitude)")
+        
+        let maxMeters = MappingTools.metersFromPixel(10, atPoint: touchPt, inMap: mapView)
+        
+        if mapView.overlays != nil {
+            for overlay: AnyObject in mapView.overlays {
+                if let lineAnnotation  = overlay as? GeoBaseEntityStyledMkPolylineAnnotation{
+                    let distance = MappingTools.distanceOfPoint(MKMapPointForCoordinate(coord), toPoly: lineAnnotation)
+                    if distance < nearestDistance || nearestDistance == -1.0 {
+                        nearestDistance=distance
+                        nearestPolyline = lineAnnotation
+                    }
+                
+                }
+               
+            }
+            if (nearestDistance <= maxMeters){
+                if let hitPolyline = nearestPolyline {
+                    selectOnMap(hitPolyline.getGeoBaseEntity())
+                }
+                
+            }
+            else {
+                println("Try Again")
+            }
+        }
+        
+    }
 }

    func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
        
        if overlay is MKPolyline {
            if overlay is StyledMkPolyline {
                var polylineRenderer = MKPolylineRenderer(overlay: overlay)
                polylineRenderer.strokeColor = UIColor(red: 228.0/255.0, green: 118.0/255.0, blue: 37.0/255.0, alpha: 0.8);
                polylineRenderer.lineWidth = 2

    
    //UITableViewDelegate
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
        selectOnMap(searchResults[indexPath.section][indexPath.row])
    }
    
    
    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
