How do I get markers to move when I zoom or pan?
bob
How do I get markers to move when I zoom or pan?
bob
Hi Bob,
Could you give more details about it here? I’m not sure whether I understood you clearly, but when I check the installed samples under “Samples/Markers”, all the markers are moving when we zoom/pan.
Thanks,
Johnny
Hi Bob,
Could you give more details about it here? I’m not sure whether I understood you clearly, but when I check the installed samples under “How Do I/Markers”, all the markers are moving when we zoom/pan.
Thanks,
Johnny
There does not seem to be a single example of zoom level changing in any of the Marker examples you suggested.
Can you tell me what event is fired when the mouse wheel is rotated over the map (and the map zooms in/out)? Maybe if I call WinformsMap.Refresh() during this event the Markers will move based on the new zoom level.
Also, I find that when the mouse wheel is used/ or I drag the map east/west, etc. the InMemoryFeatureLayer I've drawn on the map disappears. See Pictures Below:
Above the map is displayed with a SimpleMarkerLayer of Markers, and an InMemoryFeatureLayer of zip code polygons.
Above, I 've dragged the map and the Polygons disappear and the Markers stay stationary, but the underlying map moves. Looks pretty bad, what am I missing?
Thanks.
bob
Hi Bob,
Thanks for the information, the markers stuff is a bug and we have a fixed it, please get the 6.0.283.0 or 6.0.0.283 and have a try.
For the InMemoryFeatureLayer disappearing, we cannot recreate it. Could you please have a check if the style is correct at that zoom level? If there is still problem, could you please provide your sample to us?
Thanks,
Edgar
I downloaded and installed the newest DLLs (6.0.283.0), but it had NO effect. When I drag the map left/right with the mouse or Zoom the map in/out the markers stay the same as seen above.
Can you tell me what Event(s) are fired during the map drag or Zoom? Maybe I can hook into those events and force the markers to update, if so, what method on the SimpleMarkerLayer would I invoke to “redraw” the layer?
Can you tell me what you mean by “if the style is correct”? At this time, I’m just setting the individual features (polygons) as follows:
//I loop through all the zip code polygons and add each feature as follows:
PolygonShape polyShape = new PolygonShape(wkt);
feature = polyShape.GetFeature();
InternalFeatures.Add(feature);
//Then I add the MarkerLayer created above to the MapControl (WinformsMap)
MapControl.Overlays.Add(“MarkerOverlay”, MarkerLayer);
MapControl.Refresh();
Thanks.
bob
Hi Bob,
There is a MouseUp event where all the overlays will be refreshed and I guess you can try to refresh the marker overlay in there. The code just looks like : “winformsMap1.Refresh(winformsMap1.Overlays["MarkerOverlay"]);”.
Also we created a sample “DisplayASimapMap.zip” attached which I guess is similar to your scenario. Can you do some modification and see if it’s possible to reproduce the problem on your end?
For the question “if the style is correct?...”, it means that every zoom level should have a style which is used to draw the current zoomlevel layer. For example, see below codes:
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
The first line means this layer will take the “Country1” style for zoomlevel 1. Note that the AreaStyle only works on “area” data source like polygon/muliti-polygon etc. and the LineStyle only works on “road” layer like line/muliti-line. In this way, PointStyle is for point layer.
The second line means the style is the same from zoomlevel 1 to 20. So, can you check the layer’s style is correct?
Thanks,
I tried your first suggestion with No effect. So I decided to just rebuild the layers on MouseUp and that works for Draging the map.
That seems to work, but I have to test timespan so that it doesn’t try to rebuild too often.
I’m already setting the style as I have a legend and the polygons are being colored based on a value.
bob
Hi Bob,
I am bit concerned that you are needing to code a rebuild of your layers on a MouseUp event just to get them to draw. In fact the Map should be handling all of the Layer/Map updating when you pan and zoom. So unless you are trying to do something custom on the MouseUp event you should not need to code a 'Layer Rebuild' or a Map.Refresh() on a MouseUp.
In looking closely at your two screenshots I noticed that in your second image you were zoomed in to a smaller extent than in your first image. This means that the Map was also at a different (and smaller) Scale and thus the Map is looking at your InMemoryFeatureLayer's ZoomLevelSet to see what Style it should use to render the ZipCodes. If the ZipCodes are not displaying it could be that you don't have a Style setup for the current ZoomLevel (or scale) that you are currently viewing.
For example I might have a Layer that is only supposed to display from ZoomLevel01 (a world wide scale), to ZoomLevel05 (a scale that can encompass the Lower 48 states of the USA) I would setup:
private void LoadAnShapeFileFeatureLayer_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.SimpleColors.White);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level05;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("WorldLayer", worldLayer);
winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2);
winformsMap1.Refresh();
}
So what happens when I zoom the map into ZoomLevel06? The Map checks to see if there is a Style applied to my worldLayer's ZoomLevel06. Since I did not setup a style for ZoomLevel06 then the worldLayer will not be displayed. So I would first look at your ZoomLevelSet and Style setup very closely to see if that layer should even be rendered when you are zoomed into that level.
Here is the code that is being used to build add a style for shading the polygons: Did I make a mistake in setting the Zoomlevel on the third line?
DetailLayer.Open();
DetailLayer.Columns.Add(new FeatureSourceColumn("TotalSelected"));
DetailLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ClassBreakStyle Breaks = new ClassBreakStyle("TotalSelected");
for (int j = 0; j < 5; j++)
{
AreaStyle aStyle = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.FromArgb(100, legend.ScaleColors[j])));
Breaks.ClassBreaks.Add(new ClassBreak(legend.nScaleValue[j], aStyle));
}
DetailLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(Breaks);
DetailLayer.Close();
Hi Bob,
Sorry for the inconvenience, we are unable to reproduce the problem that the polygon disappears in our test code which is attached, please check it out. Would you please send us the values in “legend.nScaleValue[]” and values of the five polygons’ columnvalues[“TotalSelected”]. Or, give us a highly appreciated sample to recreate the issue.
Sorry again.
Johnny.
Post11042Sample.txt (3.04 KB)
Sorry it has taken time to get back on this response, I've been busy with other things/questions.
I'm sorry, but the build you suggested above does NOT fix the markers. They still do not move when I zoom/pan (I have last nights production build).
Thoughts? I have a temporary work around (but my boss says its unacceptable), but it really makes the map look sluggish (I clear the Markers, Polygons, etc. and rebuild).
Can you please look into this bug and let me know what I can do to correct? I'll be happy to supply you the code, but it's really basic, i.e., Build a SimpleMarkerOverlay, add Markers and then add the Overlay to the WinFormsMap Control.
Thanks.
bob
Hi Bob,
Here is the result which is produced by our sample from previous post,
original
after panning.
zoomed in
As you can see the markers move with the map, would you please check out our sample code again and tell us what we have missed in our sample. We are using the 6.0.301.0 and the 6.0.0.301.
Thanks,
Edgar
My code is really different than yours, i.e., I use a SQL Database to hold ALL data, I don't use any shape files. So my best guess is that if I attach all of the code I'm using, hopefully you can see where I might be going wrong, or might suggest a change so that the Markers, etc. will move when the map is Zoomed or Panned.
Just a quick overview of my code. The user can access a window with all of the filters that determine which Doctors are included (MapFilters). This window then executes the SQL Queries that produce the dataset, the dataset has three tables: Hospitals, Doctors and Details. The Hosptials and Doctors then produce Markers, and the Details produce Zip Code Polygons with statistical data, i.e., number of physicians in a zip code, etc.
The RebuildMap method, gets it all rolling. If I've done everything right the map (above will display..or something like it). I assume, that just panning or zooming should reposition all of the objects automatically. But it does not. I am using a licensed version of the WorldmapKit to display the underlying map.
Please see attached text file with all of the code.
If you have any questions, please let me know.
Thanks!! bob
MapTest.txt (15.6 KB)
Hi Bob,
Thanks for providing the further information, but seems that there are some variables which are not defined in the code, so we just were able to abstract some codes from your demo code, but seems like it works fine for us on our end, I’m not sure whether we missed something here, is it possible for you to provide a small “self-contained” sample for us to test, which will help us a lot to debug it and get a solution. If there are something which is not convenient to be public to the forum, you can send it to forumsupport@thinkgeo.com or create a ticket to attach it.
Looking forward to the further information and best regards,
Johnny