                 mapView.addOverlay(line); //bring the highlightedLine below the line
                 
             }
-            
+        } else {
+            selectedAnnotation=nil
+        }
+    }
+
+
+    func selectInTable(geoBaseEntityToSelect : GeoBaseEntity?){
+        if let geoBaseEntity = geoBaseEntityToSelect?{
             var kindOfGeoBaseEntity = 0;
             if geoBaseEntity is Leuchte {
                 kindOfGeoBaseEntity=LEUCHTEN

                kindOfGeoBaseEntity=MAUERLASCHEN
            }
            for i in 0...searchResults[kindOfGeoBaseEntity].count-1 {
                var leuchten : [GeoBaseEntity] = searchResults[kindOfGeoBaseEntity]
                if leuchten[i].id == geoBaseEntity.id {
                    tableView.selectRowAtIndexPath(NSIndexPath(forRow: i, inSection: kindOfGeoBaseEntity), animated: true, scrollPosition: UITableViewScrollPosition.Top)
                    break;
                }
            }
            
            
        } else {
            selectedAnnotation=nil
        }
        
        
        
    }
    
    

                
                if let hitPolyline = foundPolyline {
                    selectOnMap(hitPolyline.getGeoBaseEntity())
                    selectInTable(hitPolyline.getGeoBaseEntity())
                    println("selected Line with \(hitPolyline.pointCount) points")
                }
                else {
