当前位置: 首页 > news >正文

ArcGis Mobile根据查询出来的坐标画marker(DrawMapImage)

需求:根据查询出来的坐标串,将这些点画到地图上。画分二种,一种是画普通的点和正方形,另一种为自定义图片。

解决方法:

1、自定义CustomGraphicLayer

    public class CustomGraphicLayer : MapGraphicLayer
    {
        /// Defines a symbol class instance for displaying point
        private Symbol m_pointSymbol;
        /// Defines a CoordinateCollection instance to store custom features
        private CoordinateCollection m_coordinateCollection = new CoordinateCollection();
        /// Get or set coordinate collection stored in custom graphic layer
        public CoordinateCollection Coordinates
        {
            get
            {
                return m_coordinateCollection;
            }
            set
            {
                m_coordinateCollection = value;
            }
        }
        /// Initializes a new instance of custom graphic layer
        public CustomGraphicLayer(): base("CustomGraphicLayer")
        {
            m_pointSymbol = new Symbol(
            new PointPaintOperation(
            Color.LightGreen, 2, 10, Color.Red  , 100, 10, PointPaintStyle.Square ));
        }
        /// Draw method being called after adding to map
        protected override void Draw(Display display)
        {
            //return if display is null
            if (display == null)
                return;
            //return if drawing is cancelled
            if (display.DrawingCanceled)
                return;
            MapImage imgtemp = GetMapImage ();
            foreach ( Coordinate cd in m_coordinateCollection)
            {

                //这边每个点要是屏幕坐标才能为INT型。在进入m_coordinateCollection前,System .Drawing .Point pt = map1.ToClient(new Coordinate(s1.X, s1.Y));
                display.DrawMapImage(imgtemp, (int)cd.X, (int)cd.Y, 50);

            }
            //draw coordinate collection using DrawMultipoint method
            //display.DrawMultipoint(new Pen(Color.Red), new SolidBrush(Color.Red), 10, this.m_coordinateCollection);

    //这边这个亦可用,可画点,这边这个m_coordinateCollection要用经纬坐标

            //m_pointSymbol.DrawMultipoint(display, m_coordinateCollection);
        }
        public MapImage GetMapImage()
        {
            try
            {
                Bitmap bm = new Bitmap(@"Storage Card\marker.bmp");//要注意是手机上的图片位置。
                MapImage img = new MapImage(bm);
                return img;
            }
            catch(Exception ek)
            {
                return null;
            }

        }
        protected override void Dispose(bool disposing)
        {
            //Dispose symbol implementing IDisposible
            try
            {
                if (disposing)
                {
                    if (m_pointSymbol != null)
                        m_pointSymbol.Dispose();
                    m_pointSymbol = null;

                    m_coordinateCollection = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

    }

 

转载于:https://www.cnblogs.com/stu-xu/archive/2011/09/14/2176554.html

相关文章:

  • 什么是Heartbeat
  • hdu 4027 Can you answer these queries?
  • Windows数据类型探幽——千回百转你是谁?(1)
  • 数据库连接错误: The provider did not return a ProviderManifestToken string.
  • C#编写的winform程序打包方法
  • 2017.11.14 小组第二次例会
  • 032 文本框中的时间格式
  • hdu 4012 Paint on a Wall
  • Android开发者指南(11) —— Optimizing Apps for Android 3.0
  • C#获取当前路径的7种方法
  • android116 轮播 viewPager实现
  • 参加虚拟化达人训练营的体会
  • 转载: 关于ruby中 %Q, %q, %W, %w, %x, %r, %s 的用法
  • django专题—安装、创建项目、添加应用
  • 自定义的asp.net翻页控件
  • hexo+github搭建个人博客
  • 345-反转字符串中的元音字母
  • Angular Elements 及其运作原理
  • codis proxy处理流程
  • CoolViewPager:即刻刷新,自定义边缘效果颜色,双向自动循环,内置垂直切换效果,想要的都在这里...
  • golang中接口赋值与方法集
  • HTTP中GET与POST的区别 99%的错误认识
  • Java 网络编程(2):UDP 的使用
  • js对象的深浅拷贝
  • LeetCode算法系列_0891_子序列宽度之和
  • markdown编辑器简评
  • Next.js之基础概念(二)
  • 不发不行!Netty集成文字图片聊天室外加TCP/IP软硬件通信
  • 基于Android乐音识别(2)
  • 排序算法学习笔记
  • 浅析微信支付:申请退款、退款回调接口、查询退款
  • 容器化应用: 在阿里云搭建多节点 Openshift 集群
  • 如何实现 font-size 的响应式
  • 深度学习入门:10门免费线上课程推荐
  • 一个6年java程序员的工作感悟,写给还在迷茫的你
  •  一套莫尔斯电报听写、翻译系统
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • ionic入门之数据绑定显示-1
  • 阿里云服务器购买完整流程
  • 阿里云移动端播放器高级功能介绍
  • 小白应该如何快速入门阿里云服务器,新手使用ECS的方法 ...
  • #if和#ifdef区别
  • #stm32整理(一)flash读写
  • #我与Java虚拟机的故事#连载17:我的Java技术水平有了一个本质的提升
  • (003)SlickEdit Unity的补全
  • (1)(1.9) MSP (version 4.2)
  • (javascript)再说document.body.scrollTop的使用问题
  • (JSP)EL——优化登录界面,获取对象,获取数据
  • (ZT)一个美国文科博士的YardLife
  • (二)linux使用docker容器运行mysql
  • (论文阅读40-45)图像描述1
  • (学习日记)2024.04.04:UCOSIII第三十二节:计数信号量实验
  • (转)可以带来幸福的一本书
  • **python多态
  • ./configure,make,make install的作用