private OnlineMapsGoogleElevation(Vector2[] path, int samples, string key, string client, string signature)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.Append("https://maps.googleapis.com/maps/api/elevation/xml?sensor=false&path=");

        for (int i = 0; i < path.Length; i++)
        {
            url.Append(path[i].y).Append(",").Append(path[i].x);
            if (i < path.Length - 1)
            {
                url.Append("|");
            }
        }

        url.Append("&samples=").Append(samples);

        if (!string.IsNullOrEmpty(key))
        {
            url.Append("&key=").Append(key);
        }
        if (!string.IsNullOrEmpty(client))
        {
            url.Append("&client=").Append(client);
        }
        if (!string.IsNullOrEmpty(signature))
        {
            url.Append("&signature=").Append(signature);
        }
        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
示例#2
0
    private OnlineMapsGetElevation(Vector2[] locations, string key, string client, string signature)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://maps.googleapis.com/maps/api/elevation/xml?sensor=false&locations=";

        string[] locationsStr = new string[locations.Length];
        for (int i = 0; i < locations.Length; i++)
        {
            locationsStr[i] = locations[i].y + "," + locations[i].x;
        }

        url += string.Join("|", locationsStr);
        if (!string.IsNullOrEmpty(key))
        {
            url += "&key=" + key;
        }
        if (!string.IsNullOrEmpty(client))
        {
            url += "&client=" + client;
        }
        if (!string.IsNullOrEmpty(signature))
        {
            url += "&signature=" + signature;
        }
        www = OnlineMapsUtils.GetWWW(url);
    }
示例#3
0
    private OnlineMapsGetElevation(Vector2[] path, int samples, string key, string client, string signature)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://maps.googleapis.com/maps/api/elevation/xml?sensor=false&path={0}&samples={1}";

        string[] pathStr = new string[path.Length];
        for (int i = 0; i < path.Length; i++)
        {
            pathStr[i] = path[i].y + "," + path[i].x;
        }

        url = string.Format(url, string.Join("|", pathStr), samples);
        if (!string.IsNullOrEmpty(key))
        {
            url += "&key=" + key;
        }
        if (!string.IsNullOrEmpty(client))
        {
            url += "&client=" + client;
        }
        if (!string.IsNullOrEmpty(signature))
        {
            url += "&signature=" + signature;
        }
        www = OnlineMapsUtils.GetWWW(url);
    }
    private void LoadTile(OnlineMapsTile tile, byte[] bytes)
    {
        Texture2D texture = new Texture2D(256, 256, TextureFormat.ARGB32, map.control.mipmapForTiles);

        texture.LoadImage(bytes);
        texture.wrapMode = TextureWrapMode.Clamp;

        if (map.target == OnlineMapsTarget.texture)
        {
            tile.ApplyTexture(texture);
            map.buffer.ApplyTile(tile);
            OnlineMapsUtils.DestroyImmediate(texture);
        }
        else
        {
            tile.texture = texture;
            tile.status  = OnlineMapsTileStatus.loaded;
        }

        if (map.traffic && !string.IsNullOrEmpty(tile.trafficURL))
        {
            tile.trafficWWW             = OnlineMapsUtils.GetWWW(tile.trafficURL);
            tile.trafficWWW.customData  = tile;
            tile.trafficWWW.OnComplete += map.OnTrafficWWWComplete;
        }
    }
    /// <summary>
    /// Constructor.
    /// Use OnlineMapsOSMAPIQuery.Find for create request.
    /// </summary>
    /// <param name="data">Overpass QL request</param>
    private OnlineMapsOSMAPIQuery(string data)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://overpass-api.de/api/interpreter?data=" + OnlineMapsWWW.EscapeURL(data);

        www = OnlineMapsUtils.GetWWW(url);
    }
示例#6
0
    private OnlineMapsOpenRouteService(Vector2 start, Vector2 end, string lang, OnlineMapsOpenRouteServicePref pref, bool noMotorways, bool noTollways, Vector2[] via)
    {
        _status = OnlineMapsQueryStatus.downloading;

        StringBuilder url = new StringBuilder("http://openls.geog.uni-heidelberg.de/route?");

        url.Append("start=").Append(start.x).Append(",").Append(start.y);
        url.Append("&end=").Append(end.x).Append(",").Append(end.y);

        url.Append("&via=");
        if (via != null && via.Length > 0)
        {
            for (int i = 0; i < via.Length; i++)
            {
                url.Append(via[i].x).Append(",").Append(via[i].y);
                if (i < via.Length - 1)
                {
                    url.Append(" ");
                }
            }
        }

        url.Append("&lang=").Append(lang);
        url.Append("&distunit=KM&routepref=").Append(Enum.GetName(typeof(OnlineMapsOpenRouteServicePref), pref));
        url.Append("&weighting=Shortest");
        url.Append("&avoidAreas=&useTMC=false&noMotorways=").Append(noMotorways);
        url.Append("&noTollways=").Append(noTollways).Append("&noUnpavedroads=false&noSteps=false&noFerries=false&instructions=true");

        Debug.Log(url.ToString());

        www = OnlineMapsUtils.GetWWW(url);
    }
    private void LoadTile(OnlineMapsTile tile, byte[] bytes)
    {
        Texture2D texture = new Texture2D(0, 0, TextureFormat.RGB24, false);

        texture.LoadImage(bytes);
        texture.wrapMode = TextureWrapMode.Clamp;

        if (map.target == OnlineMapsTarget.texture)
        {
            tile.ApplyTexture(texture);
            map.buffer.ApplyTile(tile);
        }
        else
        {
            tile.texture = texture;
            tile.status  = OnlineMapsTileStatus.loaded;
        }

        if (map.traffic && !string.IsNullOrEmpty(tile.trafficURL))
        {
            if (!TryLoadTraffic(tile))
            {
                tile.trafficWWW             = OnlineMapsUtils.GetWWW(tile.trafficURL);
                tile.trafficWWW.customData  = tile;
                tile.trafficWWW.OnComplete += map.OnTrafficWWWComplete;
            }
        }
    }
示例#8
0
    private OnlineMapsGetElevation(Vector2[] locations, string key, string client, string signature)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder("https://maps.googleapis.com/maps/api/elevation/xml?sensor=false&locations=");

        for (int i = 0; i < locations.Length; i++)
        {
            url.Append(locations[i].y).Append(",").Append(locations[i].x);
            if (i < locations.Length - 1)
            {
                url.Append("|");
            }
        }

        if (!string.IsNullOrEmpty(key))
        {
            url.Append("&key=").Append(key);
        }
        if (!string.IsNullOrEmpty(client))
        {
            url.Append("&client=").Append(client);
        }
        if (!string.IsNullOrEmpty(signature))
        {
            url.Append("&signature=").Append(signature);
        }
        www = OnlineMapsUtils.GetWWW(url);
    }
    private OnlineMapsQQSearch(string key, string keyword, Params p)
    {
        StringBuilder builder = new StringBuilder("http://apis.map.qq.com/ws/place/v1/search?key=").Append(key).Append("&keyword=").Append(OnlineMapsWWW.EscapeURL(keyword));

        p.AppendParams(builder);
        www             = OnlineMapsUtils.GetWWW(builder);
        www.OnComplete += OnRequestComplete;
    }
    private OnlineMapsOpenRouteService(StringBuilder url, Params p)
    {
        _status = OnlineMapsQueryStatus.downloading;
        p.Append(url);

        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
    private OnlineMapsBingMapsElevation(Params p)
    {
        StringBuilder builder = new StringBuilder();

        p.GenerateURL(builder);
        www             = OnlineMapsUtils.GetWWW(builder);
        www.OnComplete += OnRequestComplete;
    }
示例#12
0
    private OnlineMapsFindDirectionAdvanced(string origin,
                                            string destination,
                                            OnlineMapsFindDirectionMode mode = OnlineMapsFindDirectionMode.driving,
                                            string[] waypoints = null,
                                            bool alternatives  = false,
                                            OnlineMapsFindDirectionAvoid avoid = OnlineMapsFindDirectionAvoid.none,
                                            OnlineMapsFindDirectionUnits units = OnlineMapsFindDirectionUnits.metric,
                                            string region       = null,
                                            long departure_time = -1,
                                            long arrival_time   = -1,
                                            string language     = null)
    {
        _status = OnlineMapsQueryStatus.downloading;


        string url = "https://maps.google.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false";

        url = string.Format(url, origin.Replace(" ", "+"), destination.Replace(" ", "+"));

        if (mode != OnlineMapsFindDirectionMode.driving)
        {
            url += "&mode=" + Enum.GetName(typeof(OnlineMapsFindDirectionMode), mode);
        }
        if (waypoints != null)
        {
            url += "&waypoints=optimize:true|" + String.Join("|", waypoints).Replace(" ", "+");
        }
        if (alternatives)
        {
            url += "&alternatives=true";
        }
        if (avoid != OnlineMapsFindDirectionAvoid.none)
        {
            url += "&avoid=" + Enum.GetName(typeof(OnlineMapsFindDirectionAvoid), avoid);
        }
        if (units != OnlineMapsFindDirectionUnits.metric)
        {
            url += "&units" + Enum.GetName(typeof(OnlineMapsFindDirectionUnits), units);
        }
        if (!string.IsNullOrEmpty(region))
        {
            url += "&region=" + region;
        }
        if (departure_time != -1)
        {
            url += "&departure_time=" + departure_time;
        }
        if (arrival_time != -1)
        {
            url += "&arrival_time=" + arrival_time;
        }
        if (!string.IsNullOrEmpty(language))
        {
            url += "&language=" + language;
        }

        www = OnlineMapsUtils.GetWWW(url);
    }
示例#13
0
    private OnlineMapsGoogleGeocoding(RequestParams p)
    {
        _status = OnlineMapsQueryStatus.downloading;

        StringBuilder url = new StringBuilder("https://maps.googleapis.com/maps/api/geocode/xml?sensor=false");

        p.GenerateURL(url);
        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
    private OnlineMapsGooglePlacePhoto(string key, string photo_reference, int? maxWidth, int? maxHeight)
    {
        StringBuilder builder = new StringBuilder("https://maps.googleapis.com/maps/api/place/photo?key=").Append(key);
        builder.Append("&photo_reference=").Append(photo_reference);
        if (maxWidth.HasValue) builder.Append("&maxwidth=").Append(maxWidth);
        if (maxHeight.HasValue) builder.Append("&maxheight=").Append(maxHeight);

        if (!maxWidth.HasValue && !maxHeight.HasValue) builder.Append("&maxwidth=").Append(800);

        www = OnlineMapsUtils.GetWWW(builder);
        www.OnComplete += OnRequestComplete;
    }
    private OnlineMapsBingMapsLocation(Vector2 point, string key, bool includeNeighborhood)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://dev.virtualearth.net/REST/v1/Locations/{0}?key={1}&o=xml";

        if (includeNeighborhood)
        {
            url += "&inclnb=1";
        }
        url = string.Format(url, point.y + "," + point.x, key);
        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
示例#16
0
    private OnlineMapsFindDirection(string origin, string destination, bool alternatives = false)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://maps.google.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false";

        if (alternatives)
        {
            url += "&alternatives=true";
        }
        url = string.Format(url, origin.Replace(" ", "+"), destination.Replace(" ", "+"));
        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
示例#17
0
    private OnlineMapsBingMapsLocation(Vector2 point, string key, bool includeNeighborhood)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://dev.virtualearth.net/REST/v1/Locations/{0}?key={1}&o=xml", point.y + "," + point.x, key);
        if (includeNeighborhood)
        {
            url.Append("&inclnb=1");
        }
        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
    protected OnlineMapsGoogleDirections(string origin, string destination, bool alternatives = false)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://maps.googleapis.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false", OnlineMapsWWW.EscapeURL(origin), OnlineMapsWWW.EscapeURL(destination));
        if (alternatives)
        {
            url.Append("&alternatives=true");
        }
        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
示例#19
0
    private OnlineMapsFindDirection(string origin, string destination, bool alternatives = false)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://maps.googleapis.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false", OnlineMapsWWW.EscapeURL(origin), OnlineMapsWWW.EscapeURL(destination));
        if (alternatives)
        {
            url.Append("&alternatives=true");
        }
        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
    private void Start()
    {
        api = OnlineMaps.instance;
        api.OnChangePosition += OnChangePosition;

        if (findLocationByIP)
        {
#if UNITY_EDITOR || !UNITY_WEBGL
            findByIPRequest = OnlineMapsUtils.GetWWW("http://www.geoplugin.net/php.gp");
#else
            findByIPRequest = OnlineMapsUtils.GetWWW("http://service.infinity-code.com/getlocation.php");
#endif
        }
    }
示例#21
0
    /// <summary>
    /// Constructor. \n
    /// <strong>Please do not use. </strong>\n
    /// Use OnlineMapsFindLocation.Find.
    /// </summary>
    /// <param name="address">Location title</param>
    /// <param name="latlng">Location coordinates</param>
    public OnlineMapsFindLocation(string address = null, string latlng = null)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://maps.googleapis.com/maps/api/geocode/xml?sensor=false";

        if (!string.IsNullOrEmpty(address))
        {
            url += "&address=" + address.Replace(" ", "+");
        }
        if (!string.IsNullOrEmpty(latlng))
        {
            url += "&latlng=" + latlng.Replace(" ", "");
        }
        www = OnlineMapsUtils.GetWWW(url);
    }
示例#22
0
    private void Start()
    {
        api = OnlineMaps.instance;
        api.OnChangePosition += OnChangePosition;

        if (findLocationByIP)
        {
#if UNITY_EDITOR || !UNITY_WEBGL
            OnlineMapsWWW findByIPRequest = OnlineMapsUtils.GetWWW("https://ipinfo.io/json");
#else
            OnlineMapsWWW findByIPRequest = OnlineMapsUtils.GetWWW("http://service.infinity-code.com/getlocation.php");
#endif
            findByIPRequest.OnComplete += OnFindLocationComplete;
        }
    }
    protected OnlineMapsGooglePlaces(string key, RequestParams p)
    {
        _status = OnlineMapsQueryStatus.downloading;

        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://maps.googleapis.com/maps/api/place/{0}/xml?sensor=false", p.typePath);
        if (!string.IsNullOrEmpty(key))
        {
            url.Append("&key=").Append(key);
        }
        p.AppendParams(url);

        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
    protected OnlineMapsSkobblerDirections(string start, string destination, string key)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.AppendFormat(
            "http://{0}.tor.skobbler.net/tor/RSngx/calcroute/json/20_5/en/{0}?start={1}&dest={2}&profile=carShortest&advice=yes",
            key,
            start,
            destination);

        Debug.Log(url);

        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
示例#25
0
    private OnlineMapsFindPlaces(string key, RequestParams p)
    {
        _status = OnlineMapsQueryStatus.downloading;

        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://maps.googleapis.com/maps/api/place/{0}/xml?sensor=false", p.typePath);
        if (!string.IsNullOrEmpty(key))
        {
            url.Append("&key=").Append(key);
        }
        p.AppendParams(url);

        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
 private void Download(StringBuilder url, string key, string client, string signature)
 {
     if (!string.IsNullOrEmpty(key))
     {
         url.Append("&key=").Append(key);
     }
     if (!string.IsNullOrEmpty(client))
     {
         url.Append("&client=").Append(client);
     }
     if (!string.IsNullOrEmpty(signature))
     {
         url.Append("&signature=").Append(signature);
     }
     www             = OnlineMapsUtils.GetWWW(url);
     www.OnComplete += OnRequestComplete;
 }
示例#27
0
    private OnlineMapsBingMapsLocation(string query, string key, int maxResults, bool includeNeighborhood)
    {
        _status = OnlineMapsQueryStatus.downloading;
        StringBuilder url = new StringBuilder();

        url.AppendFormat("https://dev.virtualearth.net/REST/v1/Locations/{0}?key={1}&o=xml", OnlineMapsWWW.EscapeURL(query), key);
        if (includeNeighborhood)
        {
            url.Append("&inclnb=1");
        }
        if (maxResults > 0 && maxResults != 5)
        {
            url.Append("&maxRes=").Append(maxResults);
        }
        www             = OnlineMapsUtils.GetWWW(url);
        www.OnComplete += OnRequestComplete;
    }
示例#28
0
    private OnlineMapsOSMNominatim(Vector2 location, string acceptlanguage, bool addressdetails)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://nominatim.openstreetmap.org/reverse?format=xml&lat={0}&lon={1}";

        if (addressdetails)
        {
            url += "&addressdetails=1";
        }
        if (string.IsNullOrEmpty(acceptlanguage))
        {
            url += "&accept-language=" + acceptlanguage;
        }
        url = string.Format(url, location.y, location.x);
        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
    private OnlineMapsBingMapsLocation(string query, string key, int maxResults, bool includeNeighborhood)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url = "https://dev.virtualearth.net/REST/v1/Locations/{0}?key={1}&o=xml";

        if (includeNeighborhood)
        {
            url += "&inclnb=1";
        }
        if (maxResults > 0 && maxResults != 5)
        {
            url += "&maxRes=" + maxResults;
        }
        url = string.Format(url, query.Replace(" ", "+"), key);
        www = OnlineMapsUtils.GetWWW(url);
        OnlineMaps.instance.AddGoogleAPIQuery(this);
    }
示例#30
0
    private OnlineMapsOpenRouteService(Vector2 start, Vector2 end, string lang, OnlineMapsOpenRouteServicePref pref, bool noMotorways, bool noTollways, Vector2[] via)
    {
        _status = OnlineMapsQueryStatus.downloading;
        string url    = "https://openls.geog.uni-heidelberg.de/testing2015/route?Start={0}&End={1}&Via={2}&lang={3}&distunit=KM&routepref={4}&avoidAreas=&useTMC=false&noMotorways={5}&noTollways={6}&instructions=true";
        string viaStr = "";

        if (via != null && via.Length > 0)
        {
            string[] vias = new string[via.Length];
            for (int i = 0; i < via.Length; i++)
            {
                vias[i] = via[i].x + "," + via[i].y;
            }
            viaStr = string.Join(" ", vias);
        }
        url = string.Format(url, start.x + "," + start.y, end.x + "," + end.y, viaStr, lang, Enum.GetName(typeof(OnlineMapsOpenRouteServicePref), pref), noMotorways, noTollways);
        www = OnlineMapsUtils.GetWWW(url);
    }