Exemple #1
0
    /// <summary>
    /// Checks whether the response from webservice.
    /// </summary>
    protected void OnRequestComplete(OnlineMapsWWW www)
    {
        if (www != null && www.isDone)
        {
            _status   = string.IsNullOrEmpty(www.error) ? OnlineMapsQueryStatus.success : OnlineMapsQueryStatus.error;
            _response = _status == OnlineMapsQueryStatus.success ? www.text : www.error;

            if (OnComplete != null)
            {
                OnComplete(_response);
            }
            if (this is OnlineMapsGoogleAPIQuery)
            {
                OnlineMapsGoogleAPIQuery q = this as OnlineMapsGoogleAPIQuery;
                if (q.OnFinish != null)
                {
                    q.OnFinish(q);
                }
            }
            else if (OnFinish != null)
            {
                OnFinish(this);
            }

            _status    = OnlineMapsQueryStatus.disposed;
            _response  = null;
            this.www   = null;
            customData = null;
        }
    }
        private void Start()
        {
            // Start search Chicago.
            OnlineMapsGoogleAPIQuery query = OnlineMapsFindLocation.Find("Chicago");

            // Specifies that search results should be sent to OnFindLocationComplete.
            query.OnComplete += OnFindLocationComplete;
        }
Exemple #3
0
        private void OnMapClick()
        {
            // Get elevation on click point
            OnlineMapsGoogleAPIQuery elevationRequest =
                OnlineMapsGetElevation.Find(OnlineMapsControlBase.instance.GetCoords());

            elevationRequest.OnComplete += OnComplete;
        }
        private void Start()
        {
            // Begin to search a route from Los Angeles to the specified coordinates.
            OnlineMapsGoogleAPIQuery query = OnlineMapsFindDirection.Find("Los Angeles",
                                                                          new Vector2(-118.178960f, 35.063995f));

            // Specifies that search results must be sent to OnFindDirectionComplete.
            query.OnComplete += OnFindDirectionComplete;
        }
Exemple #5
0
        private void OnMapClick()
        {
            // Get the coordinates where the user clicked.
            Vector2 mouseCoords = OnlineMapsControlBase.instance.GetCoords();

            // Try find location name by coordinates.
            OnlineMapsGoogleAPIQuery query = OnlineMapsFindLocation.Find(null, mouseCoords.y + "," + mouseCoords.x);

            query.OnComplete += OnQueryComplete;
        }
Exemple #6
0
    /// <summary>
    /// Constructor. \n
    /// Use OnlineMapsDirectionStep.TryParse.
    /// </summary>
    /// <param name="node">XMLNode of route</param>
    private OnlineMapsDirectionStep(OnlineMapsXML node)
    {
        start        = node.GetLatLng("start_location");
        end          = node.GetLatLng("end_location");
        duration     = node.Find <int>("duration/value");
        instructions = node.Find <string>("html_instructions");
        GetStringInstructions();
        distance = node.Find <int>("distance/value");

        maneuver = node.Find <string>("maneuver");

        string encodedPoints = node.Find <string>("polyline/points");

        points = OnlineMapsGoogleAPIQuery.DecodePolylinePoints(encodedPoints);
    }
Exemple #7
0
    public override void Destroy()
    {
        if (this is OnlineMapsGoogleAPIQuery)
        {
            OnlineMapsGoogleAPIQuery q = this as OnlineMapsGoogleAPIQuery;
            if (q.OnDispose != null)
            {
                q.OnDispose(q);
            }
        }
        else if (OnDispose != null)
        {
            OnDispose(this);
        }

        www        = null;
        _response  = string.Empty;
        _status    = OnlineMapsQueryStatus.disposed;
        customData = null;
        OnComplete = null;
        OnFinish   = null;
    }
Exemple #8
0
    /// <summary>
    /// Constructor of OnlineMapsFindPlacesResult.
    /// </summary>
    /// <param name="node">Place node from response</param>
    public OnlineMapsFindPlacesResult(OnlineMapsXML node)
    {
        List <OnlineMapsFindPlacesResultPhoto> photos = new List <OnlineMapsFindPlacesResultPhoto>();
        List <string> types        = new List <string>();
        List <string> weekday_text = new List <string>();

        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "name")
            {
                name = n.Value();
            }
            else if (n.name == "id")
            {
                id = n.Value();
            }
            else if (n.name == "vicinity")
            {
                vicinity = n.Value();
            }
            else if (n.name == "type")
            {
                types.Add(n.Value());
            }
            else if (n.name == "geometry")
            {
                location = OnlineMapsGoogleAPIQuery.GetVector2FromNode(n[0]);
            }
            else if (n.name == "rating")
            {
                rating = n.Value <float>();
            }
            else if (n.name == "icon")
            {
                icon = n.Value();
            }
            else if (n.name == "reference")
            {
                reference = n.Value();
            }
            else if (n.name == "place_id")
            {
                place_id = n.Value();
            }
            else if (n.name == "scope")
            {
                scope = n.Value();
            }
            else if (n.name == "price_level")
            {
                price_level = n.Value <int>();
            }
            else if (n.name == "formatted_address")
            {
                formatted_address = n.Value();
            }
            else if (n.name == "opening_hours")
            {
                open_now = n.Get <string>("open_now") == "true";
                foreach (OnlineMapsXML wdt in n.FindAll("weekday_text"))
                {
                    weekday_text.Add(wdt.Value());
                }
            }
            else if (n.name == "photo")
            {
                photos.Add(new OnlineMapsFindPlacesResultPhoto(n));
            }
            else
            {
                Debug.Log(n.name);
            }
        }

        this.photos       = photos.ToArray();
        this.types        = types.ToArray();
        this.weekday_text = weekday_text.ToArray();
    }
 /// <summary>
 /// Adds a new request to the Google API in the processing queue.
 /// </summary>
 /// <param name="query">Queue</param>
 public void AddGoogleAPIQuery(OnlineMapsGoogleAPIQuery query)
 {
     googleQueries.Add(query);
 }
 public void AddGoogleAPIQuery(OnlineMapsGoogleAPIQuery query)
 {
     googleQueries.Add(query);
 }
Exemple #11
0
    /// <summary>
    /// Constructor of OnlineMapsFindLocationResult.
    /// </summary>
    /// <param name="node">Location node from response</param>
    public OnlineMapsFindLocationResult(OnlineMapsXML node)
    {
        List <OnlineMapsFindLocationResultAddressComponent> address_components = new List <OnlineMapsFindLocationResultAddressComponent>();
        List <string> types = new List <string>();
        List <string> postcode_localities = new List <string>();

        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "type")
            {
                types.Add(n.Value());
            }
            else if (n.name == "place_id")
            {
                place_id = n.Value();
            }
            else if (n.name == "formatted_address")
            {
                formatted_address = n.Value();
            }
            else if (n.name == "address_component")
            {
                address_components.Add(new OnlineMapsFindLocationResultAddressComponent(n));
            }
            else if (n.name == "geometry")
            {
                foreach (OnlineMapsXML gn in n)
                {
                    if (gn.name == "location")
                    {
                        geometry_location = OnlineMapsGoogleAPIQuery.GetVector2FromNode(gn);
                    }
                    else if (gn.name == "location_type")
                    {
                        geometry_location_type = gn.Value();
                    }
                    else if (gn.name == "viewport")
                    {
                        geometry_viewport_northeast = OnlineMapsGoogleAPIQuery.GetVector2FromNode(gn["northeast"]);
                        geometry_viewport_southwest = OnlineMapsGoogleAPIQuery.GetVector2FromNode(gn["southwest"]);
                    }
                    else if (gn.name == "bounds")
                    {
                        geometry_bounds_northeast = OnlineMapsGoogleAPIQuery.GetVector2FromNode(gn["northeast"]);
                        geometry_bounds_southwest = OnlineMapsGoogleAPIQuery.GetVector2FromNode(gn["southwest"]);
                    }
                    else
                    {
                        Debug.Log(n.name);
                    }
                }
            }
            else if (n.name == "partial_match")
            {
                partial_match = n.Value() == "true";
            }
            else
            {
                Debug.Log(n.name);
            }
        }

        this.address_components = address_components.ToArray();
        this.types = types.ToArray();
        this.postcode_localities = postcode_localities.ToArray();
    }