`

利用JavaScript实现图片标注——SearchMapIdentityTask

阅读更多

功能:功能实现了现在网络流行的定位后在地图上画一个图标,点击图标后弹出消息框。

思路:根据查询条件获得一个点的地图坐标,然后转换为屏幕坐标,利用js脚本动态图片到相应位置。

效果图如下:

 

主要实现步骤:

1、SearchMapIdentity.cs,该类主要实现查询获取点的地图坐标,地图坐标转换为屏幕坐标的方法,点击小图标时的回发调用,代码如下:

using System;
using System.Data;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.ADF.Web.Geometry;
using ESRI.ArcGIS.ADF.Web.Display.Graphics;
using System.Collections.Generic;

namespace SearchMapIdentityTask{

   public class SearchMapIdentity
    {
        #region 私有字段
       private Page m_page;
       private Map m_map;
       private ArrayList mapPoints = null;
       private string content;
       
       private string m_callbackInvocation = "";
       private string m_filePath = "";
       private string queryText = "";
       private DataTable queryResult = null;
       private string queryField = "";
       private string readFields = "";
      #endregion

        #region 相关属性
        public Map Map
        {
            get { return m_map; }
            set { m_map = value; }
        }

        public Page Page
        {
            get { return m_page; }
            set { m_page = value; }
        }


        public string ClientCallbackInvocation
        {
            get { return m_callbackInvocation; }
            set { m_callbackInvocation = value; }
        }

        public string FilePath
        {
            get { return m_filePath; }
            set { m_filePath = value; }
        }

        public string QueryText
        {
            get { return queryText; }
            set { queryText = value; }
        }

        public ArrayList MapPoints
        {
            get { return mapPoints; }
            set { mapPoints = value; }
        }
        public string Content
        {
            get { return content; }
            set { content = value; }
        }

       public DataTable QueryResult
       {
           get { return queryResult; }
           set { queryResult = value; }
       }
       //需要用来作为Where条件的查询字段
       public string QueryField
       {
           get { return queryField; }
           set { queryField = value; }
       }
       //需要显示在详细信息里的字段
       public string ReadFields
       {
           get { return readFields; }
           set { readFields = value; }
       }
        #endregion

        #region 构造函数

        public SearchMapIdentity()
        {
        }

        public SearchMapIdentity(Map map)
        {
            if (map != null)
            {
                m_map = map;
            }
        }

        public SearchMapIdentity(Map map, string filePath)
        {
            m_map = map;
            m_filePath = filePath;

        }
        #endregion

        #region 处理点击查询回调的函数

        public void Identify(bool isFirstIdentify,string layername)
        {
            int x = 0;
            int y = 0;
            ArrayList xy = null;
            if (this.MapPoints == null || isFirstIdentify == true)
            {
                xy = GetXY(this.Map,layername);
            }
            else
            {
                xy = this.MapPoints as ArrayList;
            }
            foreach (object o in xy)
            {
                object[] arrayPoints = o as object[];
                ESRI.ArcGIS.ADF.Web.Geometry.Point p = (ESRI.ArcGIS.ADF.Web.Geometry.Point)arrayPoints[0];
                System.Drawing.Point screenPoint = MapToScreenPoint(p.X, p.Y);
                x = screenPoint.X;
                y = screenPoint.Y;
                string content = arrayPoints[1] as string;
                string oa = string.Format("ReDrawZommToPoint({0},{1},{2},{3},\'{4}\');", x, y, p.X, p.Y, content);
                CallbackResult cr1 = new CallbackResult(null, null, "javascript", oa);
                this.Map.CallbackResults.Add(cr1);
            }
        }
        #endregion

        #region 处理点击小图片时回调的函数
        public void DrawInfoWin(double mapX, double mapY, string content)
        {
            System.Drawing.Point screen_point = MapToScreenPoint(mapX, mapY);
            int[] rate = { screen_point.X, screen_point.Y - 38 };
            object[] oa = new object[1];
            string sa = "showInfoWindow(" + rate[0].ToString() + "," + rate[1].ToString() + ",'" + content + "');";
            oa[0] = sa;
            CallbackResult cr1 = new CallbackResult(null, null, "javascript", oa);
            this.Map.CallbackResults.Add(cr1);
        }
        #endregion

        #region 获得查询点的结果集
        public ArrayList GetXY(Map Map1,string layername)
        {
            ArrayList XY = new ArrayList();
            IEnumerable func_enum = Map1.GetFunctionalities();
            System.Data.DataTable datatable = null;

            foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisfunctionality in func_enum)
            {
                ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = gisfunctionality.Resource;

                if (gisfunctionality.Resource.DataSource.DataSourceDefinition == "In Memory")
                {
                    continue;
                }

                bool supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));

                if (supported)
                {
                    ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;

                    qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(
                       typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

                    string[] lids;
                    string[] lnames;
                    qfunc.GetQueryableLayers(null, out lids, out lnames);

                    int layer_index = -1;
                    for (int i = 0; i < lnames.Length; i++)
                    {
                        if (lnames[i] == layername)
                        {
                            layer_index = i;
                            break;
                        }
                    }

                    if (layer_index == -1)
                    {
                        continue;
                    }

                    ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
                    spatialfilter.Geometry = Map1.GetFullExtent();
                    spatialfilter.ReturnADFGeometries = true;
                    spatialfilter.MaxRecords = 1000;
                    spatialfilter.WhereClause = this.QueryField + " like '%" + this.QueryText + "%'";  //txtSearch.Text; 查询条件

                    datatable = qfunc.Query(null, lids[layer_index], spatialfilter);
                    this.QueryResult = datatable;

                    if (datatable != null)
                    {
                        int intShape = -1;
                        foreach (System.Data.DataColumn col in datatable.Columns)
                        {
                            if (col.DataType == typeof(Geometry))
                            {
                                intShape = col.Ordinal;
                                break;
                            }
                        }

                        for (int i = 0; i < datatable.Rows.Count; i++)
                        {
                            ESRI.ArcGIS.ADF.Web.Geometry.Point point2 = (ESRI.ArcGIS.ADF.Web.Geometry.Point)datatable.Rows[i].ItemArray[intShape];
                            //让地图以某个点居中
                            this.Map.CenterAt(point2);
                            Array readFieldPairs = this.ReadFields.Split(";".ToCharArray());
                            string[] readFieldValue;
                            //循环构造Content属性
                            if (readFieldPairs.Length > 0)
                            {
                                for (int j = 0; j < readFieldPairs.Length-1; j++)
                                {
                                    readFieldValue = readFieldPairs.GetValue(j).ToString().Split(":".ToCharArray());
                                    this.Content += readFieldValue[0] + ":" + datatable.Rows[i][readFieldValue[1]].ToString()+"<br>";
                                }
                            }                            
                            object[] arraryPoint = new object[2];
                            arraryPoint[0] = point2;
                            arraryPoint[1] = this.Content;
                            //将Content属性清空
                            this.Content = "";
                            XY.Add(arraryPoint);
                        }
                    }
                }
            }
            this.MapPoints = XY;
            return XY;

        }
        #endregion

        #region 由地图坐标经过转换得到屏幕坐标的点
        public System.Drawing.Point MapToScreenPoint(double mapX, double mapY)
        {
            ESRI.ArcGIS.ADF.Web.Geometry.Point adf_point = new ESRI.ArcGIS.ADF.Web.Geometry.Point(mapX, mapY);
            ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams transformationParameters = this.Map.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToScreen);
            System.Drawing.Point screen_point = adf_point.ToScreenPoint(transformationParameters);
            return screen_point;
        }

        #endregion

    }
}

 

2、SearchMapIdentityTask.cs,这个就是包装Task的类,主要代码如下

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.DataSources;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.ComponentModel;
using System.Text.RegularExpressions;

namespace SearchMapIdentityTask
{
   
    public class SearchMapIdentityTask : FloatingPanelTask
    {
        private TextBox textBox = null;
        private HtmlInputButton button = null;
        private HtmlSelect selLayers = null;
        private HtmlInputButton clear = null;

        SearchMapIdentity searchMapIdentity = null;
        private string queryField = "";        
        private string readFileds = "";

        #region 相关属性
        [Description("用户where条件中要查询的字段")]
        public string QueryField
        {
            get { return queryField; }
            set { queryField = value; }
        }
        [Description("设置需要在详细信息中显示的字段,格式为(字段1中文名:字段1数据库表名;字段2中文名:字段2数据库表名)")]
        public string ReadFileds
        {
            get { return readFileds; }
            set { readFileds = value; }
        }
        #endregion

        #region 构造函数
        public SearchMapIdentityTask()
        {
            this.Width = Unit.Pixel(200);
        }
        #endregion

        #region 构建子控件
        protected override void CreateChildControls()
        {
            Controls.Clear();
            base.CreateChildControls();
            textBox = new TextBox();
            textBox.ID = "textBox";
            textBox.Width=200;
            button = new HtmlInputButton();
            button.ID = "button";
            button.Value = "查询";
            clear = new HtmlInputButton();
            clear.ID = "clear";
            clear.Value = "清除结果";
            selLayers = new HtmlSelect();
            selLayers.ID = "sellayer";  
            Controls.Add(selLayers);
            Controls.Add(textBox);
            Controls.Add(button);
            Controls.Add(clear);

            string argument = string.Format("'args='+document.getElementById('{0}').value", selLayers.ClientID);
            argument += string.Format("+':'+strTrim(document.getElementById('{0}').value)", textBox.ClientID);

            string onClick = string.Format("executeTask({0},\"{1}\");", argument, base.CallbackFunctionString);
            //调用SearchMapIdentity.js里的clearIdentifyDiv函数,清楚上一次查询产生的div
            onClick += "clearIdentifyDiv();";
            string onKeyDown = string.Format(" if(event.keyCode==13) {{{0} return false;}}", onClick);
            button.Attributes.Add("onclick", onClick);
            //点击clear按钮时,调用清除查询结果的js函数
            clear.Attributes.Add("onclick", "clearIdentifyDiv()");
            textBox.Attributes.Add("onkeydown", onKeyDown);


            //调用填充下拉框函数
            FillLayerSelect();
        }
        #endregion
        
        #region OnLoad—初始化一些初始变量
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //进行相关属性检查
            if (this.QueryField == "")
            {
                throw new Exception("QueryField属性未设置");
            }

            Regex regex = new Regex("^(\\S+:\\S+;)+$");
            if (this.ReadFileds == "")
            {
                throw new Exception("ReadFileds属性未设置");
            }
            else if (!regex.IsMatch(this.ReadFileds))
            {
                throw new Exception("ReadFileds格式不正确,请查看描述后修改!");
            }

            this.MapInstance.ScaleChanged += new MapScaleChangeEventHandler(Map_ScaleChanged);
            searchMapIdentity = new SearchMapIdentity(this.MapInstance);
            searchMapIdentity.QueryField = this.QueryField;
            searchMapIdentity.ReadFields = this.ReadFileds;
            //searchMapIdentity.SetupIdentify();
            if (this.Page.Session["MapPoints"] != null)
            {
                searchMapIdentity.MapPoints = this.Page.Session["MapPoints"] as ArrayList;
            }
        }
        #endregion

        #region OnPreRender - 加载客户端脚本和设置属性

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (this.Page != null)
            {
                //注册SearchMapIdentity脚本
                ClientScriptManager scriptMgr = Page.ClientScript;
                Type controlType = this.GetType();
                string fileName = controlType.Namespace + ".SearchMapIdentity.js";
                scriptMgr.RegisterClientScriptResource(controlType, fileName);
                //注册回调的字符串
                System.Text.StringBuilder sb = new System.Text.StringBuilder();                
                sb.Append("<script language=\"javascript\" type=\"text/javascript\">var MapSearchIdentifyCallbackStr = \"" + base.CallbackFunctionString + "\";</script>\n");
                if (!Page.ClientScript.IsClientScriptBlockRegistered("MapSearchIdentify"))
                    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "MapSearchIdentify", sb.ToString());
            }            
        }
        #endregion

        #region 回调处理函数
        //得到传递进来的参数,赋给base.Input
        public override string GetCallbackResult()
        {
            NameValueCollection keyValCol1 = CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg);
            if (keyValCol1["EventArg"] == "executeTask")
            {
                string sInArgs = keyValCol1["args"];
                string delim = ":";
                char[] delchar = delim.ToCharArray();
                string[] args = sInArgs.Split(delchar);
                object[] inputs = new object[2];
                inputs[0] = args[0];
                inputs[1] = args[1];
                base.Input = inputs;
            }
            else if (keyValCol1["EventArg"] == "startTaskActivityIndicator")
            {
            }
            else if (keyValCol1["EventArg"] == "hidden")
            {
            }
            //自己添加的分支,用户处理点击小图片是的回发处理
            else if (keyValCol1["EventArg"] == "ShowInfoWin")
            {
                double MapX = Convert.ToDouble(keyValCol1["MapX"]);
                double MapY = Convert.ToDouble(keyValCol1["MapY"]);
                string content = keyValCol1["Content"];
                searchMapIdentity.DrawInfoWin(MapX, MapY, content);
                return this.MapInstance.CallbackResults.ToString();
            }
            return base.GetCallbackResult();
        }
        #endregion

        #region 执行TASK
        public override void ExecuteTask()
        {
            if (Input == null) return;
            object[] inputs = Input as object[];
            string selLayer = inputs[0] as string;
            string queryTxt = (string)inputs[1];
            ViewState["selLayer"] = selLayer;
            ViewState["queryTxt"] = queryTxt;
            searchMapIdentity.QueryText = queryTxt;
            searchMapIdentity.Identify(true, selLayer);
            DataTable datatable = searchMapIdentity.QueryResult as DataTable;
            DataSet ds = new DataSet();
            ds.Tables.Add(datatable);            
            ds.DataSetName = "查询"+ queryTxt +"的结果为:";
            Page.Session["MapPoints"] = searchMapIdentity.MapPoints;
            base.Results = ds;
        }
        #endregion

        #region 处理依赖资源
        public override List<GISResourceItemDependency> GetGISResourceItemDependencies()
        {
            throw new Exception("The method or operation is not implemented.");
        }
        #endregion

        #region 渲染控件格式
        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            this.selLayers.RenderControl(writer);
            writer.RenderEndTag();
            writer.RenderEndTag();

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (!string.IsNullOrEmpty(this.Input as string))
            {
                this.textBox.Text = this.Input as string;
            }
            else
            {
                this.textBox.Text = "";
            }
            this.textBox.RenderControl(writer);
            writer.RenderEndTag();
            writer.RenderEndTag();            

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            this.button.RenderControl(writer);
            writer.Write("  ");
            this.clear.RenderControl(writer);
            writer.RenderEndTag();
            writer.RenderEndTag();

            writer.RenderEndTag();
        }
        #endregion

        #region 辅助函数
        Map _map = null;
        TaskResults _taskResults = null;
        private Map MapInstance
        {
            get
            {
                if (_map == null)
                {
                    for (int i = 0; i < base.TaskResultsContainers.Count; i++)
                    {
                        _taskResults = Utility.FindControl(TaskResultsContainers[i].Name, Page) as TaskResults;
                        if (_taskResults != null && _taskResults.Map != null && _taskResults.Map.Length > 1)
                        {
                            _map = Utility.FindControl(_taskResults.Map, this.Page) as Map;
                        }
                        if (_map != null)
                            break;
                    }
                }
                return _map;
            }
        }

        private TaskResults getTaskResults()
        {
            if (_taskResults == null)
                _map = MapInstance;
            return _taskResults;
        }

        //填充selLayers下拉框
        private void FillLayerSelect()
        {
            ListItem layerItem;
            IMapFunctionality mf = MapInstance.GetFunctionality(0);
            if (mf == null)
            {
                layerItem = new ListItem("<no layers found>", "null");
                selLayers.Items.Add(layerItem);
                return;
            }
            IGISResource gisresource = mf.Resource;
            bool supported = gisresource.SupportsFunctionality(typeof(IQueryFunctionality));
            selLayers.Items.Clear();
            if (supported)
            {
                IQueryFunctionality qfunc = gisresource.CreateFunctionality(typeof(IQueryFunctionality), null) as IQueryFunctionality;
                string[] lids;
                string[] lnames;                
                qfunc.GetQueryableLayers(null, out lids, out lnames, ESRI.ArcGIS.ADF.Web.FeatureType.Point);
                int i = 0;
                while (i < lnames.Length)
                {
                    layerItem = new ListItem(lnames[i], lnames[i]);
                    selLayers.Items.Add(layerItem);
                    i++;
                }
            }
        }


        #endregion

        #region 地图比例尺变化以后要执行的函数
        protected void Map_ScaleChanged(object sender, ESRI.ArcGIS.ADF.Web.UI.WebControls.ScaleEventArgs args)
        {
            if (Page.IsPostBack || Page.IsCallback)
            {
                if (ViewState["selLayer"] != null && ViewState["queryTxt"] != null)
                {
                    searchMapIdentity.QueryText = "四川";
                    searchMapIdentity.Identify(false, ViewState["selLayer"] as string);
                }
            }
        }
#endregion

    }
}

 

3、SearchMapIdentity.js,主要是些动态创建和定位div的js脚本

//显示详细信息的服务器回调函数
function DrawInfowindow(mapX,mapY,content)
 {
    if (mapX==null||mapY==null) return;
    var argument="EventArg=ShowInfoWin&MapX=" + mapX + "&MapY=" + mapY + "&Content=" + content;
    var context = Maps["Map1"].controlName;
    eval(MapSearchIdentifyCallbackStr); 
 }


//删除已经标示的DIV
function clearIdentifyDiv()
{
    var o = map.overlayObject
    while (o.hasChildNodes())
     { 
       o.removeChild(o.lastChild); 
     } 
}

//将图片定位到指定点
function showZoomToPoint(x,y,mapX,mapY,content)
{
    map = Maps["Map1"];
	var pointdiv = document.createElement("div"); 
	pointdiv.style.position="absolute";	
	pointdiv.style.zIndex=2;
	// point is bottom center... 2 pixels up for shadow
	var cWidth = Math.floor(pointdiv.clientWidth / 2);
	var cHeight = pointdiv.clientHeight;
	if (cWidth==0) cWidth = 20;
	if (cHeight==0) cHeight = 38;
	var idLeft = x - parseInt(map.divObject.style.left)-cWidth/2;
	var idTop = y - parseInt(map.divObject.style.top) - cHeight + 2; 	
    pointdiv.innerHTML='<img src=images/blank.gif alt="" border="0"  hspace="0" vspace="0" onclick=\'DrawInfowindow(' + mapX + ',' + mapY + ',"' + content + '");\' style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/icon_info.png\');cursor:hand;" />\n';
	map.overlayObject.appendChild(pointdiv);  
	pointdiv.style.left= idLeft;
    pointdiv.style.top=idTop;
	return false;
}

//重新将图片定位到指定点
function ReDrawZommToPoint(x,y,mapX,mapY,content)
 {           
    window.setTimeout("showZoomToPoint(" + x + "," + y + "," + mapX + "," + mapY + ",\'" + content + "\')",1000);
 }


//显示详细信息的函数
function showInfoWindow(x,y,content)
{
	var div = document.getElementById("InfoWindow");
	if (div==null) {
	    addInfowindow();
	}
	window.status=content;
	document.getElementById("infowindowTitle").innerHTML="<b><font color='black'>详细信息</font></b>"
	var infoContentHtml="<font color='black'>" + content + "</font><br>";
	var oNearQuery=document.getElementById("tr_NearQuery");

	infoContentHtml += "<span style=\"cursor:hand;\" onclick=\"alert('call js functions u need');\"><u>点我吧</u></span> ";

	document.getElementById("infowindowContent").innerHTML= infoContentHtml ;
	var div = document.getElementById("InfoWindow");
	var cWidth = Math.floor(div.clientWidth / 2);
	var cHeight = div.clientHeight;

	if (cWidth==0) cWidth = 235;
	if (cHeight==0) cHeight = 148;
	var idLeft = x - parseInt(map.divObject.style.left) ;//- cWidth;
	var idTop = y - parseInt(map.divObject.style.top) - cHeight + 2; 
    window.setTimeout('moveLayer("InfoWindow", ' + idLeft + ', ' + idTop + '); showLayer("InfoWindow");', 0);
	return false;
	
}

//添加显示信息的div
function addInfowindow()
{
    var content="";   
    content = '<div id="InfoWindow" style="z-index:3;position:absolute; width:235px; height:148px;left: 0px; top: 0px; visibility: hidden;  overflow:hidden; background-image: url(images/Info.gif); layer-background-image: url(images/Info.gif); border: 1px none #000000; cursor:default  "><table   border="0" cellpadding="0" cellspacing="0">'; 
    content += '<tr> ';
    content += '    <td valign="top"><table width="235" border="0" cellspacing="0" cellpadding="0"> ';
    content += '      <tr> ';
    content += '        <td><table  border="0" style="overflow: hidden;height: 20px; width:235px;" cellspacing="0" cellpadding="0"> ';
    content += '          <tr> ';
    content += '            <td  id ="infowindowTitle" width="218" style="overflow: hidden; width:218px; height:20px; font:宋体;  font-size:12px; color:black; padding-left:10px; " valign="middle"></td> ';
    content += '            <td width="17" valign="middle"><img style="cursor:hand;" onclick=\'closeInfoWindow();\' onmouseover="this.src=\'images/close2.png\'" onmouseout="this.src=\'images/close1.png\'" src="images/close1.png" width="8" height="6" /></td> ';
    content += '          </tr> ';
    content += '        </table></td> ';
    content += '      </tr> ';
    content += '      <tr> ';
    content += '        <td > ';
    content += '			<table align="center" width="220" border="0" cellspacing="0" cellpadding="0"> ';
    content += '			  <tr> ';
    content += '				<td background="images/h-line.png"  style="height:1px; padding:10px"></td> ';
    content += '			  </tr>';
    content += '			</table> ';
    content += '		</td> ';
    content += '      </tr> ';
    content += '      <tr> ';
    content += '        <td style="height:125px; overflow:hidden; " valign="top"> ';
    content += '		<table width="230" style="width:230px; height:125px; overflow: hidden;" border="0" cellpadding="0" cellspacing="0"> ';
    content += '          <tr> ';
    content += '            <td valign="top"> ';
    content += '			<div  id="infowindowContent" style="overflow: hidden;height:75px; width:230px;  font-size:12px ;padding-left:10px;padding-top:10px" ></div> ';
    content += '			</td> ';
    content += '          </tr>';
    content += '        </table></td> ';
    content += '      </tr> ';
    content += '    </table></td> ';
    content += '  </tr>';
    content += '</table></div>';
    map.overlayObject.insertAdjacentHTML("BeforeEnd", content);
}

//关闭显示详细信息的div
function closeInfoWindow()
{
    var div = document.getElementById("InfoWindow");
	if (div!=null)
	{
        hideLayer("InfoWindow");
    }
}

//辅助函数——清除字符串空格
function strTrim(s)
{
    var reg=/(^\s*)|(\s*$)/g;
    var ss=s.replace(reg,"");
    return ss;
}

  

使用注意事项:

1、要把附件中的图片Info.gif、close1.png、close2.png、h-line.png、icon_info.png拷贝到测试项目的根目录下的images文件夹下面。

2、要在mxd中添加1个以上点图层。

 

分享到:
评论
2 楼 feihuangzhaodian 2009-05-14  
请问博主map.overlayObject.insertAdjacentHTML 应该也能像Google Earth一样弹出个图片来吧?
1 楼 mingkof 2009-03-08  
ReDrawZommToPoint

收藏 。研究

相关推荐

    利用JavaScript实现图片标注——SearchMapIdentityTask.doc

    在Web开发中,利用JavaScript实现图片标注是一项常用的功能,它能够帮助用户在地图上直观地定位特定地点,并提供交互式的体验。以下是对如何使用JavaScript实现图片标注的详细说明: 首先,我们需要理解核心的技术...

    SNS单模无芯光纤仿真与传感器结构特性分析——基于Rsoft beamprop模块

    内容概要:本文主要探讨了SNS单模无芯光纤的仿真分析及其在通信和传感领域的应用潜力。首先介绍了模间干涉仿真的重要性,利用Rsoft beamprop模块模拟不同模式光在光纤中的传播情况,进而分析光纤的传输性能和模式特性。接着讨论了光纤传输特性的仿真,包括损耗、色散和模式耦合等参数的评估。随后,文章分析了光纤的结构特性,如折射率分布、包层和纤芯直径对性能的影响,并探讨了镀膜技术对光纤性能的提升作用。最后,进行了变形仿真分析,研究外部因素导致的光纤变形对其性能的影响。通过这些分析,为优化光纤设计提供了理论依据。 适合人群:从事光纤通信、光学工程及相关领域的研究人员和技术人员。 使用场景及目标:适用于需要深入了解SNS单模无芯光纤特性和优化设计的研究项目,旨在提高光纤性能并拓展其应用场景。 其他说明:本文不仅提供了详细的仿真方法和技术细节,还对未来的发展方向进行了展望,强调了SNS单模无芯光纤在未来通信和传感领域的重要地位。

    发那科USM通讯程序socket-rece

    发那科USM通讯程序socket-set

    嵌入式八股文面试题库资料知识宝典-WIFI.zip

    嵌入式八股文面试题库资料知识宝典-WIFI.zip

    JS+HTML源码与image

    源码与image

    物流行业车辆路径优化:基于遗传算法和其他优化算法的MATLAB实现及应用

    内容概要:本文详细探讨了物流行业中路径规划与车辆路径优化(VRP)的问题,特别是针对冷链物流、带时间窗的车辆路径优化(VRPTW)、考虑充电桩的车辆路径优化(EVRP)以及多配送中心情况下的路径优化。文中不仅介绍了遗传算法、蚁群算法、粒子群算法等多种优化算法的理论背景,还提供了完整的MATLAB代码及注释,帮助读者理解这些算法的具体实现。此外,文章还讨论了如何通过MATLAB处理大量数据和复杂计算,以得出最优的路径方案。 适合人群:从事物流行业的研究人员和技术人员,尤其是对路径优化感兴趣的开发者和工程师。 使用场景及目标:适用于需要优化车辆路径的企业和个人,旨在提高配送效率、降低成本、确保按时交付货物。通过学习本文提供的算法和代码,读者可以在实际工作中应用这些优化方法,提升物流系统的性能。 其他说明:为了更好地理解和应用这些算法,建议读者参考相关文献和教程进行深入学习。同时,实际应用中还需根据具体情况进行参数调整和优化。

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_8.doc.zip

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_8.doc.zip

    基于灰狼优化算法的城市路径规划Matlab实现——解决TSP问题

    内容概要:本文介绍了基于灰狼优化算法(GWO)的城市路径规划优化问题(TSP),并通过Matlab实现了该算法。文章详细解释了GWO算法的工作原理,包括寻找猎物、围捕猎物和攻击猎物三个阶段,并提供了具体的代码示例。通过不断迭代优化路径,最终得到最优的城市路径规划方案。与传统TSP求解方法相比,GWO算法具有更好的全局搜索能力和较快的收敛速度,适用于复杂的城市环境。尽管如此,算法在面对大量城市节点时仍面临运算时间和参数设置的挑战。 适合人群:对路径规划、优化算法感兴趣的科研人员、学生以及从事交通规划的专业人士。 使用场景及目标:①研究和开发高效的路径规划算法;②优化城市交通系统,提升出行效率;③探索人工智能在交通领域的应用。 其他说明:文中提到的代码可以作为学习和研究的基础,但实际应用中需要根据具体情况调整算法参数和优化策略。

    嵌入式八股文面试题库资料知识宝典-Intel3.zip

    嵌入式八股文面试题库资料知识宝典-Intel3.zip

    嵌入式八股文面试题库资料知识宝典-2019京东C++.zip

    嵌入式八股文面试题库资料知识宝典-2019京东C++.zip

    嵌入式八股文面试题库资料知识宝典-北京光桥科技有限公司面试题.zip

    嵌入式八股文面试题库资料知识宝典-北京光桥科技有限公司面试题.zip

    物理学领域十字形声子晶体的能带与传输特性研究及应用

    内容概要:本文详细探讨了十字形声子晶体的能带结构和传输特性。首先介绍了声子晶体作为新型周期性结构在物理学和工程学中的重要地位,特别是十字形声子晶体的独特结构特点。接着从散射体的形状、大小、排列周期等方面分析了其对能带结构的影响,并通过理论计算和仿真获得了能带图。随后讨论了十字形声子晶体的传输特性,即它对声波的调控能力,包括传播速度、模式和能量分布的变化。最后通过大量实验和仿真验证了理论分析的正确性,并得出结论指出散射体的材料、形状和排列方式对其性能有重大影响。 适合人群:从事物理学、材料科学、声学等相关领域的研究人员和技术人员。 使用场景及目标:适用于希望深入了解声子晶体尤其是十字形声子晶体能带与传输特性的科研工作者,旨在为相关领域的创新和发展提供理论支持和技术指导。 其他说明:文中还对未来的研究方向进行了展望,强调了声子晶体在未来多个领域的潜在应用价值。

    嵌入式系统开发_USB主机控制器_Arduino兼容开源硬件_基于Mega32U4和MAX3421E芯片的USB设备扩展开发板_支持多种USB外设接入与控制的通用型嵌入式开发平台_.zip

    嵌入式系统开发_USB主机控制器_Arduino兼容开源硬件_基于Mega32U4和MAX3421E芯片的USB设备扩展开发板_支持多种USB外设接入与控制的通用型嵌入式开发平台_

    e2b8a-main.zip

    e2b8a-main.zip

    少儿编程scratch项目源代码文件案例素材-火柴人跑酷(2).zip

    少儿编程scratch项目源代码文件案例素材-火柴人跑酷(2).zip

    【HarmonyOS分布式技术】远程启动子系统详解:跨设备无缝启动与智能协同的应用场景及未来展望

    内容概要:本文详细介绍了HarmonyOS分布式远程启动子系统,该系统作为HarmonyOS的重要组成部分,旨在打破设备间的界限,实现跨设备无缝启动、智能设备选择和数据同步与连续性等功能。通过分布式软总线和分布式数据管理技术,它能够快速、稳定地实现设备间的通信和数据同步,为用户提供便捷的操作体验。文章还探讨了该系统在智能家居、智能办公和教育等领域的应用场景,展示了其在提升效率和用户体验方面的巨大潜力。最后,文章展望了该系统的未来发展,强调其在技术优化和应用场景拓展上的无限可能性。 适合人群:对HarmonyOS及其分布式技术感兴趣的用户、开发者和行业从业者。 使用场景及目标:①理解HarmonyOS分布式远程启动子系统的工作原理和技术细节;②探索该系统在智能家居、智能办公和教育等领域的具体应用场景;③了解该系统为开发者提供的开发优势和实践要点。 其他说明:本文不仅介绍了HarmonyOS分布式远程启动子系统的核心技术和应用场景,还展望了其未来的发展方向。通过阅读本文,用户可以全面了解该系统如何通过技术创新提升设备间的协同能力和用户体验,为智能生活带来新的变革。

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_1.zip

    嵌入式八股文面试题库资料知识宝典-C and C++ normal interview_1.zip

    少儿编程scratch项目源代码文件案例素材-激光反弹.zip

    少儿编程scratch项目源代码文件案例素材-激光反弹.zip

    COMSOL相控阵检测技术在有机玻璃斜楔中检测工件内部缺陷的应用研究

    内容概要:本文详细介绍了COMSOL相控阵检测技术在有机玻璃斜楔上放置16阵元进行工件内部缺陷检测的方法。首先阐述了相控阵检测技术的基本原理,特别是通过控制各阵元的激发时间和相位来实现声波的聚焦和扫描。接着,重点解析了横孔缺陷的反射接收波,解释了波的折射现象及其背后的物理原因。最后,通过实例展示了COMSOL模拟声波传播过程的成功应用,验证了该技术的有效性和准确性。 适合人群:从事固体力学、无损检测领域的研究人员和技术人员,尤其是对相控阵检测技术和COMSOL仿真感兴趣的读者。 使用场景及目标:适用于需要精确检测工件内部缺陷的研究和工业应用场景,旨在提高检测精度和效率,确保产品质量和安全。 其他说明:文中提到的声速匹配现象有助于理解波在不同介质间的传播特性,这对优化检测参数设置有重要意义。

Global site tag (gtag.js) - Google Analytics