• 基于地图开发控件GMap.Net 使用 (五) 原创 用户自定义标签图片


    最近看到 fangping朋友的提问问是否可以自定义标签,相信大家对此问题都挺关注。回头看看Gmap动态库还真没提供此功能。自己添加一个!打开开源源码创建一个类名为GMapMarkerImage的类。此类功能:用户可添加自定义图片标签。

    添加源码如下:

    View Code
    public class GMapMarkerImage : GMapMarker
    {
    public float? Bearing;

    private Image userImage=null;

    public GMapMarkerImage(PointLatLng p)
    :
    base(p)
    {
    Size
    = new System.Drawing.Size(Resources.bigMarkerGreen.Width, Resources.bigMarkerGreen.Height);
    Offset
    = new Point(-10, -34);
    }

    public GMapMarkerImage(PointLatLng p ,string imageFile)
    :
    base(p)
    {
    Size
    = new System.Drawing.Size(Resources.bigMarkerGreen.Width, Resources.bigMarkerGreen.Height);
    Offset
    = new Point(-10, -34);
    try
    {
    userImage
    = Bitmap.FromFile(imageFile);
    userImage
    = new Bitmap(0, 0);
    }
    catch
    {

    }
    }

    public GMapMarkerImage(PointLatLng p, Image imageFile)
    :
    base(p)
    {
    Size
    = new System.Drawing.Size(Resources.bigMarkerGreen.Width, Resources.bigMarkerGreen.Height);
    Offset
    = new Point(-10, -34);
    userImage
    = imageFile;
    }

    static readonly Point[] Arrow = new Point[] { new Point(-7, 7), new Point(0, -22), new Point(7, 7), new Point(0, 2) };

    public override void OnRender(Graphics g)
    {
    #if !PocketPC

    g.TranslateTransform(ToolTipPosition.X, ToolTipPosition.Y);

    g.ResetTransform();

    if (!Bearing.HasValue)
    {
    g.DrawImageUnscaled(userImage, LocalPosition.X, LocalPosition.Y);
    }
    #else
    DrawImageUnscaled(g, Resources.shadow50, LocalPosition.X, LocalPosition.Y);
    DrawImageUnscaled(g, Resources.marker, LocalPosition.X, LocalPosition.Y);
    #endif
    base.OnRender(g);
    }

    喜洋洋同学就到地图上面了

  • 相关阅读:
    CSDN文章列表的CSS实现
    Arcgis for Js之鼠标经过显示对象名的实现
    Java ssh 访问windows/Linux
    HTTP长连接实现“服务器推”的技术
    Eclipse设置、调优、使用
    Quartz的配置文件quartz.properties详解
    Quartz所使用的表的说明
    Quartz动态添加、修改和删除定时任务
    Quartz的misfire特性
    项目中使用Quartz集群分享--转载
  • 原文地址:https://www.cnblogs.com/liuyunsheng/p/2068381.html
Copyright © 2020-2023  润新知