public void Search(string address, string customFilter, string proximity) { esTransactionScope.IsolationLevel = IsolationLevel.ReadUncommitted; int searchRadius; if (!int.TryParse(proximity, out searchRadius)) { searchRadius = 10; } List <ViewAbleMarker> markers = new List <ViewAbleMarker>(); Coordinates geoResult = new Coordinates() { GeocodeSuccess = false }; if (!string.IsNullOrEmpty(address)) { geoResult = GeocodeLocation(address); } if (geoResult.GeocodeSuccess) { var markersCollection = new MarkerCollection(); markersCollection.LoadByProximity(geoResult.Latitude, geoResult.Longitude, searchRadius, customFilter, ModuleId); markersCollection.ToList().ForEach(marker => markers.Add(new ViewAbleMarker(marker))); litMarkers.Text = SerializeMarkers(markers); if ((Settings[ModuleSettingNames.SearchResultsTemplate] != null)) { string template = Convert.ToString(Settings[ModuleSettingNames.SearchResultsTemplate]); litSearchResults.Text = ReplaceTokens(markers, template, ModuleId).ToString(); } if (markers.Count == 0) { LoadMembers(); LoadControls(); litError.Text = "We currently do not have any locations that match your criteria"; pnlNoMatches.Visible = true; litMarkers.Text = SerializeMarkers(LoadMarkers(ModuleId)); } } else { LoadMembers(); LoadControls(CustomFilterSelection); if (!string.IsNullOrEmpty(address)) { litError.Text = "Unable to geocode address"; pnlNoMatches.Visible = true; } litMarkers.Text = !string.IsNullOrEmpty(CustomFilterSelection) ? SerializeMarkers(LoadMarkers(ModuleId, CustomFilterSelection)) : SerializeMarkers(LoadMarkers(ModuleId)); } }
public List <ViewAbleMarker> LoadMarkers(int moduleId, string customFieldFilter = "") { var markers = new List <ViewAbleMarker>(); var markerQuery = new MarkerQuery(); var markerCollection = new MarkerCollection(); markerQuery.Where(markerQuery.ModuleId == moduleId && markerQuery.Latitude.IsNotNull() && markerQuery.Longitude.IsNotNull()).OrderBy("Priority").OrderBy(markerQuery.Title.Ascending); if (HidePointsOnPageLoad) { MaxPoints = 0; markerQuery.es.Top = MaxPoints; } if (!string.IsNullOrEmpty(customFieldFilter)) { markerQuery.Where(markerQuery.CustomField.Like(String.Format("%{0}%", customFieldFilter))); } markerCollection.Load(markerQuery); markerCollection.ToList().ForEach(marker => markers.Add(new ViewAbleMarker(marker))); return(markers); }