示例#1
0
    public IEnumerator GetImage(GoogleMapPath path, int index, Action <ActionResults> action)
    {
        //Debug.Log("act=" + threadId + " BEGIN");

        var image = new Texture2D(GMapManager.Size, GMapManager.Size);

        ReqAnswer req = null;

        StartCoroutine(_remoteManager.GetUrl(GMapManager.GetUrl(path), true, x => req = x));
        while (req == null)
        {
            yield return(null);
        }

        if (req.Exception == null)
        {
            image.LoadImage(req.Response.Bytes);
        }
        action(new ActionResults(image, index));
    }
示例#2
0
    //Последовательность
    //Первым делом берем нужный участок голый (без маршрутов)
    //Далее запрос той же местности + координаты участка (N раз), тоесть имею N+1 изображение
    //Далее сравниваю все N изображений по пиксельно с исходным, рисую карту разниц, типа если не совпало тикущее с исходным, значит на результирующем надо отрисовать


    public GoogleMapPath GetPathFromString(string coords)
    {
        var p = new GoogleMapPath();

        try
        {
            coords = coords.Trim();
            if (coords[coords.Length - 1] == ';')
            {
                coords = coords.Remove(coords.Length - 1);
            }

            p.color = GoogleMapColor.red;

            var locat = new List <GoogleMapLocation>();
            foreach (var c in coords.Split(';'))
            {
                var l = new GoogleMapLocation();
                try
                {
                    l.latitude  = float.Parse(c.Split(',')[0]);
                    l.longitude = float.Parse(c.Split(',')[1]);
                    locat.Add(l);
                }
                catch (Exception e)
                {
                    Debug.Log(e.Message + "=" + c);
                    throw;
                }
            }
            p.locations = locat;
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);
            throw;
        }
        return(p);
    }
示例#3
0
    public IEnumerator GetImage(int threadId, GoogleMapPath path, int index, Action <ActionResults> action)
    {
        Debug.Log("act=" + threadId + " BEGIN");

        var image = new Texture2D(size, size);
        var qs    = "";

        if (!autoLocateCenter)
        {
            if (!string.IsNullOrEmpty(centerLocation.address))
            {
                qs += "center=" + HTTP.URL.Encode(centerLocation.address);
            }
            else
            {
                qs += "center=" + HTTP.URL.Encode(string.Format("{0},{1}", centerLocation.latitude, centerLocation.longitude));
            }
            qs += "&zoom=" + zoom.ToString();
        }
        qs += "&size=" + HTTP.URL.Encode(string.Format("{0}x{0}", size));
        qs += "&scale=" + (doubleResolution ? "2" : "1");
        qs += "&maptype=" + mapType.ToString().ToLower();
        qs += "&format=png32";//только его не размывает

        //var usingSensor = false;
        //qs += "&sensor=" + (usingSensor ? "true" : "false");

        foreach (var i in markers)
        {
            qs += "&markers=" + string.Format("size:{0}|color:{1}|label:{2}", i.size.ToString().ToLower(), i.color, i.label);
            foreach (var loc in i.locations)
            {
                if (loc.address != "")
                {
                    qs += "|" + HTTP.URL.Encode(loc.address);
                }
                else
                {
                    qs += "|" + HTTP.URL.Encode(string.Format("{0},{1}", loc.latitude, loc.longitude));
                }
            }
        }

        if (path != null)
        {
            qs += "&path=" + string.Format("weight:{0}|color:{1}", path.weight, "0xff0000ff");
            if (path.fill)
            {
                qs += "|fillcolor:" + path.fillColor;
            }
            qs += "|enc:" + EncodePolyline.EncodeCoordinates(path.locations);
        }
        qs += "&key=AIzaSyAzduON1ycPY7318RfjwIjI3vtnWN8xb_s";

        //Debug.Log("before get =" + url + "?" + qs);
        //Debug.Log("url len=" + (url + "?" + qs).Length);
        var req = new HTTP.Request("GET", url + "?" + qs, true);

        req.Send();

        while (!req.isDone)
        {
            yield return(null);
        }

        //Debug.Log("after get=" + req.response.Bytes.Length);
        try
        {
            //Debug.Log("act=" + threadId + " after get data=" + req.response.message);
        }
        catch
        {
        }

        if (req.exception == null)
        {
            image.LoadImage(req.response.Bytes);
        }
        else
        {
            //Debug.Log("after get ex=" + req.exception.Message);
        }
        Debug.Log("act=" + threadId + " END");
        action(new ActionResults(image, index));
    }