Hi,
I have setup a map with a PostgreSqlFeatureLayer as the code below, but on clicking a station point no one feature is found. am I doing something wrong ?
Thanks in advance
Paolo Saudin
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { /* * map properties */ Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")); Map1.MapUnit = GeographyUnit.Meter; /* * map tools */ Map1.MapTools.OverlaySwitcher.Enabled = true; Map1.MapTools.OverlaySwitcher.BackgroundColor = GeoColor.StandardColors.Lavender; Map1.MapTools.OverlaySwitcher.BaseOverlayTitle = "Mappa"; Map1.MapTools.OverlaySwitcher.DynamicOverlayTitle = "Layers"; Map1.MapTools.PanZoomBar.Enabled = true; Map1.MapTools.PanZoomBar.IsGlobeButtonEnabled = false; Map1.MapTools.MouseCoordinate.Enabled = true; Map1.MapTools.MouseMapTool.Enabled = true; Map1.MapTools.ScaleLine.Enabled = true; /* * main layer */ GoogleOverlay googleOverlay = new GoogleOverlay("GoogleOverlay"); googleOverlay.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUri"]); googleOverlay.GoogleMapType = GoogleMapType.Normal; /* * stations layer */ PostgreSqlFeatureLayer stationsLayer = null; string connectString = "Server=localhost;User Id=postgres;Password=postgres;DataBase=rete_llpp;"; stationsLayer = new PostgreSqlFeatureLayer(connectString, "metadati_postgis", "st_id", 23032, "metadata", "geometria"); stationsLayer.Name = "Stations Layer"; stationsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.DarkBlue), 9); stationsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level12; /* * manage the projection */ Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(23032); proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); /* * create overlays */ // stations LayerOverlay stationsOverlay = null; if (stationsLayer != null) { stationsOverlay = new LayerOverlay("Stations Overlay", false, TileType.SingleTile); // , false, TileType.SingleTile stationsOverlay.Layers.Add("Stations Layer", stationsLayer); stationsOverlay.TransitionEffect = TransitionEffect.None; stationsLayer.FeatureSource.Projection = proj4; } /* * finally add all the layers */ if (googleOverlay != null) { Map1.CustomOverlays.Add(googleOverlay); } if (stationsOverlay != null) { Map1.CustomOverlays.Add(stationsOverlay); } /* * sets the extents */ stationsLayer.Open(); Map1.CurrentExtent = stationsLayer.GetBoundingBox(); stationsLayer.Close(); } } protected void Map1_Click(object sender, MapClickedEventArgs e) { LayerOverlay staticOverlay = (LayerOverlay)Map1.CustomOverlays["Stations Overlay"]; PostgreSqlFeatureLayer shapeFileLayer = (PostgreSqlFeatureLayer)(staticOverlay.Layers[0]); PointShape pointShape = (PointShape)e.Position; string connectString = "Server=localhost;User Id=postgres;Password=postgres;DataBase=rete_llpp;"; shapeFileLayer.ConnectionString = connectString; shapeFileLayer.Open(); Collection<Feature> selectedFeatures = shapeFileLayer.QueryTools.GetFeaturesContaining(pointShape, ReturningColumnsType.AllColumns); shapeFileLayer.Close(); CloudPopup popup; if (Map1.Popups.Count == 0) { popup = new CloudPopup("Popup", e.Position, string.Empty, 260, 60); popup.IsVisible = true; Map1.Popups.Add(popup); } else { popup = (CloudPopup)Map1.Popups["Popup"]; popup.Position = e.Position; } popup.ContentHtml = GetPopupContent(selectedFeatures); } private static string GetPopupContent(Collection<Feature> features) { string content; if (features.Count > 0) { StringBuilder message = new StringBuilder(); message.AppendFormat(" string messageInPopup = String.Format("{0}", message.ToString()); content = messageInPopup; } else { content = @"Clicca su di un punto per ottenere le informazioni."; } return content; }