ThinkGeo.com    |     Documentation    |     Premium Support

How many Marker Overlays allowed?

 I am trying to create multiple Marker Overlays with different characteristics (some represent doctors, some represent hospitals).  My code looks like this:


InMemoryMarkerOverlay doclayer = DefineMarkerLayer(mDoctorLayer, Images); //Builds Layer


InMemoryMarkerOverlay hosplayer = DefineMarkerLayer(mHospitalLayer, Images);  //Builds Layer


MapControl.Overlays.Add("DoctorOverlay", doclayer);


MapControl.Overlays.Add("HospitalOverlay", hosplayer);


How can I have both layers display?  Only the Hospital layer displays, when I comment out the Hospital Layer the Doctor Layer displays.


Thanks!!


bob


 


 


 



Hi Bob,


There must be something wrong in the DefineMarkerLayer method, I can get two markerOverlay displayed with the following code:



        private void Form_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
            AddMarkerOverlay(new Feature(0 ,0));
            AddMarkerOverlay(new Feature(-95.2806, 38.9554));
            winformsMap1.Refresh();
        }

        private void AddMarkerOverlay(Feature newFeature)
        {
            InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay();
            markerOverlay.MapControl = winformsMap1;
            markerOverlay.Columns.Add(new FeatureSourceColumn("Name"));
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Image = Properties.Resources.AQUA;
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Width = 20;
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.Height = 34;
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.YOffset = -17;
            markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultPointMarkerStyle.ToolTipText = "This is [#Name#].";
            markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            winformsMap1.Overlays.Add(markerOverlay);

            newFeature.ColumnValues.Add("Name", "Lawrence");

            markerOverlay.FeatureSource.BeginTransaction();
            markerOverlay.FeatureSource.AddFeature(newFeature);
            markerOverlay.FeatureSource.CommitTransaction();
        }


Hope it helps,


Edgar



Hi Edgar


The sample code does not work for me. It always show the marker on the overlay added the last. Please advise


Thanks


Yi



Hi Yi,


We answered you in the other post, please check it: gis.thinkgeo.com/Support/Dis...fault.aspx


Thanks,


Edgar