Hello
I am drawing bitmap icon in my map by using point shape with bitmap type definition (the point is inserted into InMemoryFeaturLayer)
When the user perform Zoom out the Bitmap of the point stay very big in non proportional size in comparison to other shapes in the layer like rectangles or regular point
How can I change/ control the size of bitmap point when changing the zoom level
I attached two screen shots
Icon1 - here you can see the icons in initial state
Icon2 - here the user perform zoom out ,the icons are very big while regular point shape presented in a good size
This is how I crate the point: I am using a point shape with a custom style and set the point.PointType = PointType.Bitmap;
case DrawModeEnum.Icon:
feature.ColumnValues[ColumnNameEnum.Feature_Name.ToString()] = "Icon";
ValueStyle vs = new ValueStyle();
vs.ColumnName = ColumnNameEnum.Feature_Id.ToString();
ValueItem vi = new ValueItem();
vi.Value = feature.Id;
ps = new PointStyle(new GeoImage(Configuration.IconsPath + "\" + StateManager.Instance().SelectedDefaultIcon));
ps.PointType = PointType.Bitmap;
vi.CustomStyles.Add(ps);
vs.ValueItems.Add(vi);
feature.ColumnValues[ColumnNameEnum.ApplyDefaultPointStyle.ToString()] = "no";
inMemoryLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(vs);
break;
Thank you very much
Miri
Bitmap point shape size in zoom out is very big
Hi Miri,
Looks like your attached files are missing.
We have a sample named ScalingImageStyle and I guess that is what you are looking for. Would you please check it?
wiki.thinkgeo.com/wiki/Map_Suite_Services_Edition_All_Samples#Scaling_Image_Style
Thanks,
Troy
Thank you , this sample did helped
I have a few problems regarding this issue:
1. In my application I have a custom value style that contains a ScalingTextStyle definition for a scale-able text
ValueItem vItem = vs.ValueItems.FirstOrDefault(i => i.Value == fc.Id);
ScalingTextStyle ts = vItem.CustomStyles.FirstOrDefault() as ScalingTextStyle;
GeoFont newFont = new GeoFont(SelectedTextStyleFontFamilyItem.ToString(), SelectedTextStyleFontSize, SelectedTextStyleFontStyleItem);
ts.Font = newFont;
GeoSolidBrush fillSolidBrush = new GeoSolidBrush(new GeoColor(SelectedFillColor.A, SelectedFillColor.R, SelectedFillColor.G, SelectedFillColor.B)); ;
ts.Mask.FillSolidBrush = fillSolidBrush;
GeoSolidBrush newGeoSolidBrush = new GeoSolidBrush(new GeoColor(SelectedOutlineColor.A,SelectedOutlineColor.R,SelectedOutlineColor.G,SelectedOutlineColor.B));;
ts.TextSolidBrush = newGeoSolidBrush;
inMemoryLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(vs);
The problem is that, as you can see we need to set the "background" color of the text by doing the following:
s.Mask.FillSolidBrush = fillSolidBrush;
In your sample the ScalingTextStyle class implement the DrawCore function and draw the text on the canvas like so:
canvas.DrawText(Text, new GeoFont(this.Font.FontName, labelSize, this.Font.Style), this.TextSolidBrush,
null, new ScreenPointF[] { textScreenPoint }, DrawingLevel.LevelFour,
this.XOffsetInPixel , this.YOffsetInPixel - labelSize, (float)this.RotationAngle);
I can not see any parameter equivalent to Mask.FillSolidBrush in the DrawText function
I tried to add a draw of an area shape with the required fill color from Mask.FillSolidBrush but it did not worked:
canvas.DrawArea(feature.GetBoundingBox(), this.Mask.FillSolidBrush, DrawingLevel.LevelFour);
Do you have any suggestions?
This situation is very problematic because with the use of ScalingTextStyle I can have a good sizing behavior on different zoom level but I can not use a custom text style that change the background color of the text
2. In the custom style of the text, the user can change the font size as you can see in the code
ts.Font = newFont;
but the DrawCore calculation (in your example) only takes into account the "min/max" size and "currentScale" but it does not consider the actual size derision of the font itself . This means the no mater what is the font size the text will be sized only according to the current wold extent
double currentScale = ExtentHelper.GetScale(canvas.CurrentWorldExtent, canvas.Width, mapUnit);
// Enforce the minimum and maximum scale properties
if (currentScale > maximumScale) { currentScale = maximumScale; }
if (currentScale < minimumScale) { currentScale = minimumScale; }
float labelSize = (float)(maximumLabelSize - ((currentScale - minimumScale) * (maximumLabelSize - minimumLabelSize)) /
(maximumScale - minimumScale));
how should I insert the Font.size of the textStyle in the above calculations?
Thank you very much
Hi Miri,
1. The textStyle.Mask is a areaStyle, that meant you should want to draw a areastyle as backgroud before you call canvas.DrawText.
2. Yes you’re right, the sample font only related with current scale, if you want it related with fontSize also, you should want to define a basic unit in your project. For example, if you think you want to use font size 7 equal basic unit, then when you set font size equal 14, you should want to make the labelSize multiply by 2.
In fact because our map contains the zoomlevel, if you don’t want to use the scaling dynamic calculate, you can directly set different style for each zoomlevel.
Regards,
Don
1.regarding to your answer
"The textStyle.Mask is a areaStyle, that meant you should want to draw a areastyle as backgroud before you call canvas.DrawText. "
yes this is exactly what I did,
I called to
canvas.DrawArea(feature.GetBoundingBox(), this.Mask.FillSolidBrush, DrawingLevel.LevelFour);
and then to
canvas.DrawText(Text, new GeoFont(this.Font.FontName, labelSize, this.Font.Style), this.TextSolidBrush,
null, new ScreenPointF[] { textScreenPoint }, DrawingLevel.LevelFour,
this.XOffsetInPixel , this.YOffsetInPixel - labelSize, (float)this.RotationAngle);
But it did not worked. Can you please attach a specific code example.
2. regarding to the second answer - thanks, I will try it
Hi Miri,
I am sorry we don’t have an exsiting sample for that, could you please upload your sample code so we can see what happened and modify it for you?
Regards,
Don