예제 #1
0
        /// <summary>
        /// 定位,国内精确判断,国外粗略
        /// </summary>
        /// <param name="longitude">经度</param>
        /// <param name="latitude">纬度</param>
        /// <returns></returns>
        public static string Location(double longitude, double latitude)
        {
            if (longitude < 0 || latitude < 0)
            {
                string key = GetForeignerMapFindKey(longitude, latitude);
                string location;
                ForeignerPostionDic.TryGetValue(key, out location);

                return(location ?? DefaultLocation);
            }

            Country.ClearPositionNear();

            var gcj  = GPS.Gcj_encrypt(latitude, longitude);
            var bd   = GPS.Bd_encrypt(gcj[0], gcj[1]);
            var area = China.Position(new MapPoint(bd[1], bd[0]));

            if (area != null)
            {
                return(area.Name);
            }
            else
            {
                var near = Country.GetNearPosition(new MapPoint(longitude, latitude));
                if (near != null)
                {
                    return(near.Name);
                }

                string key = GetForeignerMapFindKey(longitude, latitude);
                string location;
                ForeignerPostionDic.TryGetValue(key, out location);

                return(location ?? DefaultLocation);
            }
        }