Ejemplo n.º 1
0
        //百度坐标转墨卡托
        public static PointF LatLng2Mercator(LatLngPoint p)
        {
            double[] arr   = null;
            double   n_lat = p.Lat > 74 ? 74 : p.Lat;

            n_lat = n_lat < -74 ? -74 : n_lat;
            for (var i = 0; i < array1.Length; i++)
            {
                if (p.Lat >= array1[i])
                {
                    arr = array2[i];
                    break;
                }
            }
            if (arr == null)
            {
                for (var i = array1.Length - 1; i >= 0; i--)
                {
                    if (p.Lat <= -array1[i])
                    {
                        arr = array2[i];
                        break;
                    }
                }
            }
            double[] res = Convertor(p.Lng, p.Lat, arr);
            return(new PointF((float)res[0], (float)res[1]));
        }
Ejemplo n.º 2
0
 private void Start()
 {
     image = new GameObject().AddComponent <RawImage>();
     container.parent.GetComponent <DragImage>().RegisterDragEvent(UpdateTileOffectOfMove);
     latLngPoint = new LatLngPoint(0, 0);
     r_L         = row_L;
     r_R         = row_R;
     c_T         = col_T;
     c_B         = col_B;
     LoadTileShell();
     InitMap();
 }
Ejemplo n.º 3
0
        void SetTileYPos(int x, int y, int i, MoveState_T state)
        {
            int   xV    = 0;
            int   yV    = 0;
            float hight = 0;
            int   rem   = 0;
            int   div   = 0;
            float xPos  = 0;
            float yPos  = 0;

            yV = y + i;
            if (yV >= levelOffect[level].indexB && yV <= levelOffect[level].indexT)
            {
                RawImage img = null;
                for (int j = row_L; j <= row_R; j++)
                {
                    xV  = x + j;
                    rem = xV % mul;
                    div = Mathf.Abs(xV / mul);
                    if (xV < levelOffect[level].indexL)
                    {
                        if (rem < levelOffect[level].indexL)
                        {
                            xPos = (2 * size - levelOffect[level].widthL - levelOffect[level].widthR) * (div + 1);
                            xV   = rem + mul;
                        }
                        else
                        {
                            xPos = (2 * size - levelOffect[level].widthL - levelOffect[level].widthR) * div;
                            xV   = rem;
                        }
                    }
                    else if (xV > levelOffect[level].indexR)
                    {
                        if (rem > levelOffect[level].indexR)
                        {
                            xPos = (levelOffect[level].widthL + levelOffect[level].widthR - 2 * size) * (div + 1);
                            xV   = rem - mul;
                        }
                        else
                        {
                            xPos = (levelOffect[level].widthL + levelOffect[level].widthR - 2 * size) * div;
                            xV   = rem;
                        }
                    }
                    else
                    {
                        xPos = 0;
                        yPos = 0;
                    }
                    hight = size * j;
                    if (state == MoveState_T.buttom)
                    {
                        img = container.Find(j + "_" + col_T).GetComponent <RawImage>();
                        img.rectTransform.anchoredPosition = new Vector2(hight, -size) + new Vector2(xPos, yPos) + lastVect_B;
                    }
                    else if (state == MoveState_T.top)
                    {
                        img = container.Find(j + "_" + col_B).GetComponent <RawImage>();
                        img.rectTransform.anchoredPosition = new Vector2(hight, size) + new Vector2(xPos, yPos) + lastVect_T;
                    }
                    img.name    = j + "_" + i;
                    img.texture = null;
                    if (!texture_rawDic.ContainsKey(img.transform.GetChild(0).name))
                    {
                        texture_rawDic.Add(img.transform.GetChild(0).name, j + "_" + i);
                    }
                    else
                    {
                        rawDic.Remove(texture_rawDic[img.transform.GetChild(0).name]);
                    }
                    rawDic.Add(j + "_" + i, new RawImageV(img, "http://online1.map.bdimg.com/onlinelabel/?qt=tile" + $"&x={xV}&y={yV}&z={level}"));
                }
                if (state == MoveState_T.buttom)
                {
                    lastVect_B = new Vector2(0, img.rectTransform.anchoredPosition.y);
                    col_B--;
                    col_T--;
                    lastVect_T = new Vector2(0, container.Find(row_L + "_" + col_T).GetComponent <RectTransform>().anchoredPosition.y);
                    centerY--;
                }
                else if (state == MoveState_T.top)
                {
                    lastVect_T = new Vector2(0, img.rectTransform.anchoredPosition.y);
                    col_T++;
                    col_B++;
                    lastVect_B = new Vector2(0, container.Find(row_L + "_" + col_B).GetComponent <RectTransform>().anchoredPosition.y);
                    centerY++;
                }
            }
            else
            {
                Debug.Log("超出矩形限制范围");
            }
            latLngPoint = BDMapTool.Tile2LngLat(centerX, centerY, level);
            lon         = (float)latLngPoint.Lng;
            lat         = (float)latLngPoint.Lat;
        }
Ejemplo n.º 4
0
        void SetTileXPos(int x, int y, int i, MoveState_L state)
        {
            int   xV    = 0;
            int   yV    = 0;
            int   rem   = 0;
            int   div   = 0;
            float xPos  = 0;
            float yPos  = 0;
            float hight = 0;

            xV  = x + i;
            rem = xV % mul;
            div = xV / mul;
            float rectX = 0;

            if (state == MoveState_L.left)
            {
                if (xV == levelOffect[level].indexR + mul * div)
                {
                    xPos = (size / 2 - levelOffect[level].widthL) + (size / 2 - levelOffect[level].widthR) + size;
                }
                else if (xV == levelOffect[level].indexL + mul * div - 1)
                {
                    rectX = size - levelOffect[level].widthR;
                    xPos  = (size / 2 - levelOffect[level].widthL) + (size / 2 - levelOffect[level].widthR) + size;
                }
                else if (xV == levelOffect[level].indexL + mul * div)
                {
                    rectX = size - levelOffect[level].widthL;
                }
                centerX--;
            }
            else if (state == MoveState_L.right)
            {
                if (xV == levelOffect[level].indexL + mul * div)
                {
                    xPos = -((size / 2 - levelOffect[level].widthL) + (size / 2 - levelOffect[level].widthR) + size);
                }
                else if (xV == levelOffect[level].indexR + mul * div + 1)
                {
                    xPos  = -((size / 2 - levelOffect[level].widthL) + (size / 2 - levelOffect[level].widthR) + size);
                    rectX = size - levelOffect[level].widthL;
                }
                else if (xV == levelOffect[level].indexR + mul * div)
                {
                    rectX = size - levelOffect[level].widthR;
                }
                centerX++;
            }
            if (xV < levelOffect[level].indexL)
            {
                if (rem < levelOffect[level].indexL)
                {
                    xV = rem + mul;
                }
                else
                {
                    xV = rem;
                }
            }
            else if (xV > levelOffect[level].indexR)
            {
                if (rem > levelOffect[level].indexR)
                {
                    xV = rem - mul;
                }
                else
                {
                    xV = rem;
                }
            }
            RawImage img = null;

            for (int j = col_B; j <= col_T; j++)
            {
                yV    = y + j;
                hight = size * j;
                if (state == MoveState_L.left)
                {
                    img = container.Find(row_R + "_" + j).GetComponent <RawImage>();
                    img.rectTransform.anchoredPosition = new Vector2(-size, hight) + new Vector2(xPos, yPos) + lastVect_L;
                }
                else if (state == MoveState_L.right)
                {
                    img = container.Find(row_L + "_" + j).GetComponent <RawImage>();
                    img.rectTransform.anchoredPosition = new Vector2(size, hight) + new Vector2(xPos, yPos) + lastVect_R;
                }
                img.name    = i + "_" + j;
                img.texture = null;
                if (!texture_rawDic.ContainsKey(img.transform.GetChild(0).name))
                {
                    texture_rawDic.Add(img.transform.GetChild(0).name, i + "_" + j);
                }
                else
                {
                    rawDic.Remove(texture_rawDic[img.transform.GetChild(0).name]);
                }
                rawDic.Add(i + "_" + j, new RawImageV(img, "http://online1.map.bdimg.com/onlinelabel/?qt=tile" + $"&x={xV}&y={yV}&z={level}"));
            }
            if (state == MoveState_L.left)
            {
                lastVect_L = new Vector2(img.rectTransform.anchoredPosition.x, 0);
                row_L--;
                row_R--;
                lastVect_R = new Vector2(container.Find(row_R + "_" + col_B).GetComponent <RectTransform>().anchoredPosition.x, 0);
                if (lastVect_L.x + pposX + rectX - size / 2 - rect.x > 0)
                {
                    SetTileXPos(x, y, row_L - 1, state);
                }
            }
            else if (state == MoveState_L.right)
            {
                lastVect_R = new Vector2(img.rectTransform.anchoredPosition.x, 0);
                row_R++;
                row_L++;
                lastVect_L = new Vector2(container.Find(row_L + "_" + col_B).GetComponent <RectTransform>().anchoredPosition.x, 0);
                if (lastVect_R.x + pposX - rectX + size / 2 < rect.width)
                {
                    SetTileXPos(x, y, row_R + 1, state);
                }
            }
            latLngPoint = BDMapTool.Tile2LngLat(centerX, centerY, level);
            lon         = (float)latLngPoint.Lng;
            lat         = (float)latLngPoint.Lat;
        }