I created an info pop up and added the has close button but the Pop up will not close when its clicks the program thinks the map is being clicked again. i cant click on anything inside the pop up, the first is my javascript with the click event and the second is my controller, keep in mind this worked until a few days ago
JAVASCRIPT
function mapClick(d) {// Get the OpenLayers map objectolMap = Map1.getOpenLayersMap();
// Remove any existing popups from the mapfor (var i = 0; i < olMap.popups.length; i++) {olMap.removePopup(olMap.popups<i>);}
// Call the ClickEvent server action with the clicked point’s world coordinates and current map scalevar params = { x: d.worldXY.lon, y: d.worldXY.lat, scale: olMap.getScale()};Map1.ajaxCallAction(“Home.mvc”, ‘ClickEvent’, params, function (result) {// The callback contains a JSON string representing a popup balloon for the mapvar popupJson = null;var returnString = result.get_responseData();if (returnString != “”) {popupJson = JSON.parse(returnString);}
// Create a new OpenLayers popup object from the returned JSON and add it to the mapif (popupJson != null) {var olPopup = new Popup(popupJson, null);olMap.addPopup(olPopup.element);Map1.ajaxCallAction(“Home.mvc”, ‘ZoomToShape’, params, callback);}});//Map1.ajaxCallAction(“Home.mvc”, ‘ZoomToShape’, params, callback);// Redraw the WellOverlay layerMap1.redrawLayer(“Wilson Parcels”);Map1.redrawLayer(“Wilson Subdivisions”);Map1.redrawLayer(“Wilson TownShips”);Map1.redrawLayer(“Wilson Sections”);}
public string ClickEvent(Map map, GeoCollection<object> args){// Argument reference:// 0: World longitude coordinate (x)// 1: World latitude coordinate (y)// 2: Current scale of the map
string popupJson = string.Empty;int clickRadius;double currentScale;PointShape position = new PointShape(Convert.ToDouble(args[0]), Convert.ToDouble(args[1]));// Wilson Parcel OverlayLayerOverlay overlay = (LayerOverlay)map.CustomOverlays[“Wilson Parcels”];ShapeFileFeatureLayer inm = overlay.Layers[0] as ShapeFileFeatureLayer;inm.Open();InMemoryFeatureLayer highlightLayer = overlay.Layers[“HighlightLayerP”] as InMemoryFeatureLayer;highlightLayer.Open();
if (overlay.IsVisible != false){// Get a list of all the columns in the parcel layer (we’ll need this for the GetFeaturesNearestTo method)Collection<FeatureSourceColumn> parcelLayerColumns = inm.FeatureSource.GetColumns();List<string> parcelLayerColumnNames = new List<string>();foreach (FeatureSourceColumn col in parcelLayerColumns){parcelLayerColumnNames.Add(col.ColumnName);}
// Adjust the click radius based on the scale of the map (via event args) for better UX – capped at 6400 meters (approx. 4 miles)if (Double.TryParse(args[2].ToString(), out currentScale) && Int32.TryParse(Math.Ceiling(currentScale / 100).ToString(), out clickRadius)){if (clickRadius > 6400 || clickRadius <= 0){clickRadius = 6400;}}else{clickRadius = 6400;}
// Create a new CloudPopup and set some common propertiesCloudPopup infoPopup = new CloudPopup(“ParcelInfoPopup”);infoPopup.HasCloseButton = true;infoPopup.AutoPan = true;infoPopup.AutoSize = true;
// Open the highlightLayer for editing and clear any existing highlight pointshighlightLayer.FeatureSource.Open();highlightLayer.FeatureSource.BeginTransaction();highlightLayer.InternalFeatures.Clear();
// Use GetFeaturesNearestTo instead of GetFeaturesWithinDistanceOf so that the first feature returned is always closest to the click pointCollection<Feature> closestFeature = inm.FeatureSource.GetFeaturesNearestTo(position, map.MapUnit, 1, parcelLayerColumnNames as IEnumerable<string>, clickRadius, DistanceUnit.Meter);if (closestFeature.Any()){// Add a copy of this feature to the highlightLayerhighlightLayer.FeatureSource.AddFeature(closestFeature[0]);
// Create a popup with info about this featureStringBuilder message = new StringBuilder();message.AppendFormat("<li>Parcel Id:{0}</li>", closestFeature[0].ColumnValues[“PARCELID”].Trim());message.AppendFormat("<li>Owner: {0}</li>", closestFeature[0].ColumnValues[“OWNER”].Trim());//message.AppendFormat("<li>Owner Addr: {0}</li>", closestFeature[0].ColumnValues[“OWNADDR”].Trim());message.AppendFormat("<li>Quick Ref ID: {0}</li>", closestFeature[0].ColumnValues[“QuickRefID”].Trim());message.AppendFormat("<li>Acres: {0}</li>", closestFeature[0].ColumnValues[“CalcAcres”].Trim());message.AppendFormat("<li>Tax Unit : {0}</li>", closestFeature[0].ColumnValues[“TAXUNIT”].Trim());message.AppendFormat("<inputname=‘TaxData’type=‘button’id=‘btnCIC’value=‘Tax Data’onclick=‘test1()’/>");message.AppendFormat("<inputname=‘OrionData’type=‘button’id=‘btnOrion’value=‘Orion Data’onclick=‘test1()’/>");message.AppendFormat("<inputname=‘Photo’type=‘button’id=‘btnPhoto’value=‘Photo’onclick=‘test1()’/>");message.AppendFormat("<inputname=‘SVQ’type=‘button’id=‘btnSvS’value=‘SVQ’onclick=‘test1()’/>");string messageInPopup = String.Format("<divclass=\"normalBlueTx\">{0}</div>", message.ToString());
infoPopup.ContentHtml = messageInPopup;infoPopup.Position = closestFeature[0].GetShape().GetCenterPoint();}else{// Create a default instructional popupinfoPopup.ContentHtml = “<divclass=\"normalBlueTx\">Please click on a Parcel to show its information.</div>”;infoPopup.Position = position;}
// Commit changes to the highlightLayerhighlightLayer.FeatureSource.CommitTransaction();highlightLayer.FeatureSource.Close();
// Clear the map’s Popups collection and add our new onemap.Popups.Clear();map.Popups.Add(infoPopup);
// Convert the popup to JSON and return it to the clientpopupJson = infoPopup.ToJson();return popupJson;}
