public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text) { // Offset stackOffset, Mapsui.Geometries.Point p = viewport.WorldToScreen(point); //var pointF = new xPointF((float)p.X, (float)p.Y); var label = new CATextLayer (); var aString = new Foundation.NSAttributedString (text, new CoreText.CTStringAttributes(){ Font = new CoreText.CTFont("ArialMT", 10) }); var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString)); //label.Frame = frame; //frame.Width = (float)(p2.X - p1.X);// + margin); //frame.Height = (float)(p1.Y - p2.Y); label.FontSize = 10; label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150); label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150); label.String = text; label.Frame = frame; Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height); // = MonoTouch.UIKit.UIScreen.MainScreen.Scale; // label.ContentsScale = scale; return label; }
private static void MapControlMouseInfoDown(object sender, Mapsui.Windows.MouseInfoEventArgs e) { if (!e.LayerName.Equals(Constants.flagLayerName) || e.Feature == null) return; //if (e.Feature == null) return; var username = e.Feature["username"].ToString(); var flagid = e.Feature["flagid"].ToString(); var comment = e.Feature["comment"].ToString(); var longitude = e.Feature["longitude"]; var latitude = e.Feature["latitude"]; var fiw = new FlagInfoWindow(username, flagid, comment, (double)longitude, (double)latitude); fiw.Show(); }
public static CALayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IViewport viewport) { //Offset stackOffset, //return RenderLabel(point, stackOffset, style, viewport, style.Text); return new CALayer (); }
private static CGColor ToCGColor(Mapsui.Styles.Color color) { return new CoreGraphics.CGColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); }
public static UIElement RenderLabel(Mapsui.Geometries.Point point, Offset stackOffset, LabelStyle style, IViewport viewport, string text) { Mapsui.Geometries.Point p = viewport.WorldToScreen(point); var windowsPoint = new WinPoint(p.X, p.Y); var border = new Border(); var textblock = new TextBlock(); //Text textblock.Text = text; //Colors textblock.Foreground = new SolidColorBrush(style.ForeColor.ToXaml()); border.Background = new SolidColorBrush(style.BackColor.Color.ToXaml()); //Font textblock.FontFamily = new FontFamily(style.Font.FontFamily); textblock.FontSize = style.Font.Size; //set some defaults which should be configurable someday const double witdhMargin = 3.0; const double heightMargin = 0.0; textblock.Margin = new Thickness(witdhMargin, heightMargin, witdhMargin, heightMargin); border.CornerRadius = new CornerRadius(4); border.Child = textblock; //Offset var textWidth = textblock.ActualWidth; var textHeight = textblock.ActualHeight; #if !SILVERLIGHT && !NETFX_CORE // in WPF the width and height is not calculated at this point. So we use FormattedText getTextWidthAndHeight(ref textWidth, ref textHeight, style, text); #endif border.SetValue(Canvas.LeftProperty, windowsPoint.X + style.Offset.X + stackOffset.X - (textWidth + 2 * witdhMargin) * (short)style.HorizontalAlignment * 0.5f); border.SetValue(Canvas.TopProperty, windowsPoint.Y + style.Offset.Y + stackOffset.Y - (textHeight + 2 * heightMargin) * (short)style.VerticalAlignment * 0.5f); return border; }
public static UIElement RenderLabel(Mapsui.Geometries.Point point, Offset stackOffset, LabelStyle style, IViewport viewport) { return RenderLabel(point, stackOffset, style, viewport, style.Text); }
public void ZoomToBox(Mapsui.Geometries.Point beginPoint, Mapsui.Geometries.Point endPoint) { double x, y, resolution; var width = Math.Abs(endPoint.X - beginPoint.X); var height = Math.Abs(endPoint.Y - beginPoint.Y); if (width <= 0) return; if (height <= 0) return; ZoomHelper.ZoomToBoudingbox(beginPoint.X, beginPoint.Y, endPoint.X, endPoint.Y, ActualWidth, out x, out y, out resolution); resolution = ZoomHelper.ClipToExtremes(map.Resolutions, resolution); viewport.Center = new Mapsui.Geometries.Point(x, y); viewport.Resolution = resolution; toResolution = resolution; OnViewChanged(true, true); Redraw(); ClearBBoxDrawing(); }