获取地图连接 初始化地图连接

 /// <summary>
    /// 获取地图连接
    /// </summary>
    /// <returns></returns>
    public static IMap GetIMap()
    {
        string address = ConfigurationSettings.AppSettings["MapServer_Address"].ToString();
        int port = int.Parse(ConfigurationSettings.AppSettings["MapServer_Port"].ToString());
        string mapname = ConfigurationSettings.AppSettings["MapName"].ToString();
        //这里的Application["m_map"]不要随便改名字,它跟TcpMapHandler.ashx有关联
        IMap m_map = null;
        if (System.Web.HttpContext.Current.Application["m_map"] == null)
        {
            m_map = TcpMap.Create(address, port, new Hashtable());
            System.Web.HttpContext.Current.Application["m_map"] = m_map;
        }
        else
        {
            m_map = (IMap)System.Web.HttpContext.Current.Application["m_map"];
        }
        MapParam mp = new MapParam();
        mp.MapName = mapname;
        MapImage mimg = m_map.GetMapImage(mp);
        return m_map;
    }
原文地址:https://www.cnblogs.com/gaoyuchuanIT/p/1742538.html