Exemplo n.º 1
0
    /// <summary>
    /// Converts XMLNode coordinates from Google Maps into Vector2.
    /// </summary>
    /// <param name="node">XMLNode coordinates from Google Maps.</param>
    /// <returns>Coordinates as Vector2.</returns>
    public static Vector2 GetVector2FromNode(OnlineMapsXML node)
    {
        float lng = node.Get <float>("lng");
        float lat = node.Get <float>("lat");

        return(new Vector2(lng, lat));
    }
    public OnlineMapsGoogleElevationResult(OnlineMapsXML node)
    {
        elevation  = node.Get <float>("elevation");
        resolution = node.Get <float>("resolution");

        OnlineMapsXML locationNode = node["location"];

        location = new Vector2(locationNode.Get <float>("lng"), locationNode.Get <float>("lat"));
    }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="node">Term node from response.</param>
 public Term(OnlineMapsXML node)
 {
     try
     {
         value  = node.Get <string>("value");
         offset = node.Get <int>("height");
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 4
0
 public PlusCode(OnlineMapsXML node)
 {
     try
     {
         global_code   = node.Get <string>("global_code");
         compound_code = node.Get <string>("compound_code");
     }
     catch
     {
     }
 }
 /// <summary>
 /// Constructor of OnlineMapsFindAutocompleteResultTerm.
 /// </summary>
 /// <param name="node">Term node from response.</param>
 public OnlineMapsFindAutocompleteResultTerm(OnlineMapsXML node)
 {
     try
     {
         value  = node.Get <string>("value");
         offset = node.Get <int>("height");
     }
     catch (Exception)
     {
     }
 }
 /// <summary>
 /// Constructor of OnlineMapsFindAutocompleteResultMatchedSubstring.
 /// </summary>
 /// <param name="node">MatchedSubstring node from response.</param>
 public OnlineMapsFindAutocompleteResultMatchedSubstring(OnlineMapsXML node)
 {
     try
     {
         length = node.Get <int>("length");
         offset = node.Get <int>("height");
     }
     catch (Exception)
     {
     }
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="node">MatchedSubstring node from response.</param>
 public MatchedSubstring(OnlineMapsXML node)
 {
     try
     {
         length = node.Get <int>("length");
         offset = node.Get <int>("height");
     }
     catch (Exception)
     {
     }
 }
        public Route(OnlineMapsXML node)
        {
            List <Leg>    legs          = new List <Leg>();
            List <int>    waypointOrder = new List <int>();
            List <string> warnings      = new List <string>();

            foreach (OnlineMapsXML n in node)
            {
                if (n.name == "summary")
                {
                    summary = n.Value();
                }
                else if (n.name == "leg")
                {
                    legs.Add(new Leg(n));
                }
                else if (n.name == "copyrights")
                {
                    copyrights = n.Value();
                }
                else if (n.name == "overview_polyline")
                {
                    overview_polylineD = OnlineMapsUtils.DecodePolylinePointsD(n["points"].Value()).ToArray();
                    overview_polyline  = overview_polylineD.Select(p => (Vector2)p).ToArray();
                }
                else if (n.name == "waypoint_index")
                {
                    waypointOrder.Add(n.Value <int>());
                }
                else if (n.name == "warning")
                {
                    warnings.Add(n.Value());
                }
                else if (n.name == "fare")
                {
                    fare = new Fare(n);
                }
                else if (n.name == "bounds")
                {
                    OnlineMapsXML sw = n["southwest"];
                    OnlineMapsXML ne = n["northeast"];
                    bounds = new OnlineMapsGPXObject.Bounds(sw.Get <double>("lng"), sw.Get <double>("lat"), ne.Get <double>("lng"), ne.Get <double>("lat"));
                }
                else
                {
                    Debug.Log("Route: " + n.name + "\n" + n.outerXml);
                }
            }

            this.legs      = legs.ToArray();
            waypoint_order = waypointOrder.ToArray();
            this.warnings  = warnings.ToArray();
        }
Exemplo n.º 9
0
        public OnlineMapsUpdateItem(OnlineMapsXML node)
        {
            version   = node.Get <string>("Version");
            type      = node.Get <int>("Type");
            changelog = node.Get <string>("ChangeLog");
            download  = node.Get <string>("Download");
            date      = node.Get <string>("Date");

            string[] vars  = version.Split(new[] { '.' });
            string[] vars2 = new string[4];
            vars2[0] = vars[0];
            vars2[1] = int.Parse(vars[1].Substring(0, 2)).ToString();
            vars2[2] = int.Parse(vars[1].Substring(2, 2)).ToString();
            vars2[3] = int.Parse(vars[1].Substring(4, 4)).ToString();
            version  = string.Join(".", vars2);
        }
    /// <summary>
    /// Constructor of OnlineMapsGooglePlaceDetailsResult.
    /// </summary>
    /// <param name="node">Place node from response.</param>
    public OnlineMapsGooglePlaceDetailsResult(OnlineMapsXML node)
    {
        this.node              = node;
        formatted_address      = node.Get("formatted_address");
        formatted_phone_number = node.Get("formatted_phone_number");

        OnlineMapsXML locationNode = node.Find("geometry/location");

        if (!locationNode.isNull)
        {
            location = new Vector2(locationNode.Get <float>("lng"), locationNode.Get <float>("lat"));
        }

        icon = node.Get("icon");
        id   = node.Get("id");
        international_phone_number = node.Get("international_phone_number");
        name = node.Get("name");

        OnlineMapsXMLList photosList = node.FindAll("photo");

        photos = new OnlineMapsGooglePlacesResult.Photo[photosList.count];
        for (int i = 0; i < photosList.count; i++)
        {
            photos[i] = new OnlineMapsGooglePlacesResult.Photo(photosList[i]);
        }

        place_id    = node.Get <string>("place_id");
        price_level = node.Get("price_level", -1);
        rating      = node.Get <float>("rating");
        reference   = node.Get("reference");

        OnlineMapsXMLList typeNode = node.FindAll("type");

        types = new string[typeNode.count];
        for (int i = 0; i < typeNode.count; i++)
        {
            types[i] = typeNode[i].Value();
        }

        url        = node.Get("url");
        utc_offset = node.Get("utc_offset");
        vicinity   = node.Get("vicinity");
        website    = node.Get("website");
    }
Exemplo n.º 11
0
    /// <summary>
    /// Constructor of OnlineMapsFindPlacesResultPhoto.
    /// </summary>
    /// <param name="node">Photo node from response</param>
    public OnlineMapsFindPlacesResultPhoto(OnlineMapsXML node)
    {
        try
        {
            width           = node.Get <int>("width");
            height          = node.Get <int>("height");
            photo_reference = node["photo_reference"].Value();

            List <string> html_attributions = new List <string>();
            foreach (OnlineMapsXML ha in node.FindAll("html_attributions"))
            {
                html_attributions.Add(ha.Value());
            }
            this.html_attributions = html_attributions.ToArray();
        }
        catch (Exception)
        {
        }
    }
    /// <summary>
    /// Converts the route obtained by OnlineMapsFindDirection, to array of list of the steps of the route.
    /// </summary>
    /// <param name="route">Route obtained by OnlineMapsFindDirection.</param>
    /// <returns>Array of list of OnlineMapsDirectionStep or null.</returns>
    public static List <OnlineMapsDirectionStep>[] TryParseWithAlternatives(string route)
    {
        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(route);

            OnlineMapsXML direction = xml.Find("//DirectionsResponse");
            if (direction.isNull)
            {
                return(null);
            }

            string status = direction.Get <string>("status");
            if (status != "OK")
            {
                return(null);
            }

            OnlineMapsXMLList routes = direction.FindAll("route");
            List <OnlineMapsDirectionStep>[] result = new List <OnlineMapsDirectionStep> [routes.count];

            for (int i = 0; i < routes.count; i++)
            {
                OnlineMapsXMLList legNodes = routes[i].FindAll("leg");
                if (legNodes == null || legNodes.count == 0)
                {
                    continue;
                }

                List <OnlineMapsDirectionStep> steps = new List <OnlineMapsDirectionStep>();

                foreach (OnlineMapsXML legNode in legNodes)
                {
                    OnlineMapsXMLList stepNodes = legNode.FindAll("step");
                    if (stepNodes.count == 0)
                    {
                        continue;
                    }

                    foreach (OnlineMapsXML step in stepNodes)
                    {
                        OnlineMapsDirectionStep navigationStep = new OnlineMapsDirectionStep(step);
                        steps.Add(navigationStep);
                    }
                }

                result[i] = steps;
            }

            return(result);
        }
        catch { }

        return(null);
    }
Exemplo n.º 13
0
        private void LoadState()
        {
            if (!PlayerPrefs.HasKey(key))
            {
                return;
            }

            OnlineMaps api = OnlineMaps.instance;

            OnlineMapsXML prefs = OnlineMapsXML.Load(PlayerPrefs.GetString(key));

            OnlineMapsXML generalSettings = prefs["General"];

            api.position = generalSettings.Get <Vector2>("Coordinates");
            api.zoom     = generalSettings.Get <int>("Zoom");

            List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

            api.markers = markers.ToArray();
        }
        /// <summary>
        /// Loading saved state.
        /// </summary>
        private void LoadState()
        {
            if (!PlayerPrefs.HasKey(key))
            {
                return;
            }

            OnlineMaps map = OnlineMaps.instance;

            OnlineMapsXML prefs = OnlineMapsXML.Load(PlayerPrefs.GetString(key));

            OnlineMapsXML generalSettings = prefs["General"];

            map.position = generalSettings.Get <Vector2>("Coordinates");
            map.zoom     = generalSettings.Get <int>("Zoom");

            List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

            OnlineMapsMarkerManager.SetItems(markers);
        }
Exemplo n.º 15
0
        private void OnMarkerClick(OnlineMapsMarkerBase marker)
        {
            // Try get XML from customData.
            OnlineMapsXML xml = marker.customData as OnlineMapsXML;

            if (xml == null)
            {
                Debug.Log("The marker does not contain XML.");
                return;
            }

            // Show xml in console.
            Debug.Log(xml.outerXml);
            Debug.Log(xml.Get("ID"));
        }
    /// <summary>
    /// Converts response into an array of results.
    /// </summary>
    /// <param name="response">Response of Google API.</param>
    /// <returns>Array of result.</returns>
    public static OnlineMapsGoogleElevationResult[] GetResults(string response)
    {
        OnlineMapsXML xml = OnlineMapsXML.Load(response);

        if (xml.isNull || xml.Get <string>("status") != "OK")
        {
            return(null);
        }

        List <OnlineMapsGoogleElevationResult> rList = new List <OnlineMapsGoogleElevationResult>();

        foreach (OnlineMapsXML node in xml.FindAll("result"))
        {
            rList.Add(new OnlineMapsGoogleElevationResult(node));
        }

        return(rList.ToArray());
    }
Exemplo n.º 17
0
    private static void LoadControl(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase control = api.GetComponent<OnlineMapsControlBase>();
        if (control == null) return;

        control.allowAddMarkerByM = el.Get<bool>("AllowAddMarkerByM");
        control.allowZoom = el.Get<bool>("AllowZoom");
        control.allowUserControl = el.Get<bool>("AllowUserControl");
        control.zoomInOnDoubleClick = el.Get<bool>("ZoomInOnDoubleClick");

        if (control is OnlineMapsControlBase3D)
        {
            OnlineMapsControlBase3D control3D = control as OnlineMapsControlBase3D;

            control3D.allowAddMarker3DByN = el.Get<bool>("AllowAddMarker3DByN");
            control3D.allowCameraControl = el.Get<bool>("AllowCameraControl");
            control3D.marker2DMode = (OnlineMapsMarker2DMode)el.Get<int>("Marker2DMode");
            control3D.marker2DSize = el.Get<float>("Marker2DSize");
            control3D.marker3DScale = el.Get<float>("Marker3DScale");
            control3D.activeCamera = GetObject(el.Get<int>("Camera")) as Camera;

            if (control3D.allowCameraControl)
            {
                control3D.cameraDistance = el.Get<float>("CameraDistance");
                control3D.cameraRotation = el.Get<Vector2>("CameraRotation");
                control3D.cameraSpeed = el.Get<Vector2>("CameraSpeed");
            }
        }

        if (control is OnlineMapsTileSetControl)
        {
            OnlineMapsTileSetControl ts = control as OnlineMapsTileSetControl;

            ts.checkMarker2DVisibility = (OnlineMapsTilesetCheckMarker2DVisibility)el.Get<int>("CheckMarker2DVisibility");
            ts.smoothZoom = el.Get<bool>("SmoothZoom");
            ts.useElevation = el.Get<bool>("UseElevation");
            ts.tileMaterial = GetObject(el.Get<int>("TileMaterial")) as Material;
            ts.tilesetShader = GetObject(el.Get<int>("TileShader")) as Shader;
            ts.drawingShader = GetObject(el.Get<int>("DrawingShader")) as Shader;
            ts.markerMaterial = GetObject(el.Get<int>("MarkerMaterial")) as Material;
            ts.markerShader = GetObject(el.Get<int>("MarkerShader")) as Shader;
        }
    }
    /// <summary>
    /// Constructor of OnlineMapsFindPlacesResultPhoto.
    /// </summary>
    /// <param name="node">Photo node from response</param>
    public OnlineMapsFindPlacesResultPhoto(OnlineMapsXML node)
    {
        try
        {
            width = node.Get<int>("width");
            height = node.Get<int>("height");
            photo_reference = node["photo_reference"].Value();

            List<string> html_attributions = new List<string>();
            foreach (OnlineMapsXML ha in node.FindAll("html_attributions")) html_attributions.Add(ha.Value());
            this.html_attributions = html_attributions.ToArray();
        }
        catch (Exception)
        {
        }
    }
Exemplo n.º 19
0
    private static void LoadControl(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase control = api.GetComponent <OnlineMapsControlBase>();

        if (control == null)
        {
            return;
        }

        control.allowAddMarkerByM   = el.Get <bool>("AllowAddMarkerByM");
        control.allowZoom           = el.Get <bool>("AllowZoom");
        control.allowUserControl    = el.Get <bool>("AllowUserControl");
        control.zoomInOnDoubleClick = el.Get <bool>("ZoomInOnDoubleClick");

        if (control is OnlineMapsControlBase3D)
        {
            OnlineMapsControlBase3D control3D = control as OnlineMapsControlBase3D;

            control3D.allowAddMarker3DByN = el.Get <bool>("AllowAddMarker3DByN");
            control3D.allowCameraControl  = el.Get <bool>("AllowCameraControl");
            control3D.marker2DMode        = (OnlineMapsMarker2DMode)el.Get <int>("Marker2DMode");
            control3D.marker2DSize        = el.Get <float>("Marker2DSize");
            control3D.marker3DScale       = el.Get <float>("Marker3DScale");
            control3D.activeCamera        = GetObject(el.Get <int>("Camera")) as Camera;

            if (control3D.allowCameraControl)
            {
                control3D.cameraDistance = el.Get <float>("CameraDistance");
                control3D.cameraRotation = el.Get <Vector2>("CameraRotation");
                control3D.cameraSpeed    = el.Get <Vector2>("CameraSpeed");
            }
        }

        if (control is OnlineMapsTileSetControl)
        {
            OnlineMapsTileSetControl ts = control as OnlineMapsTileSetControl;

            ts.checkMarker2DVisibility = (OnlineMapsTilesetCheckMarker2DVisibility)el.Get <int>("CheckMarker2DVisibility");
            ts.smoothZoom     = el.Get <bool>("SmoothZoom");
            ts.useElevation   = el.Get <bool>("UseElevation");
            ts.tileMaterial   = GetObject(el.Get <int>("TileMaterial")) as Material;
            ts.tilesetShader  = GetObject(el.Get <int>("TileShader")) as Shader;
            ts.drawingShader  = GetObject(el.Get <int>("DrawingShader")) as Shader;
            ts.markerMaterial = GetObject(el.Get <int>("MarkerMaterial")) as Material;
            ts.markerShader   = GetObject(el.Get <int>("MarkerShader")) as Shader;
        }
    }
Exemplo n.º 20
0
    private static void LoadSettings(OnlineMapsXML el, OnlineMaps api)
    {
        api.position = el.Get <Vector2>("Position");
        api.zoom     = el.Get <int>("Zoom");

        if (api.target == OnlineMapsTarget.texture)
        {
            api.texture = GetObject(el.Get <int>("Texture")) as Texture2D;
        }
        else
        {
            api.tilesetWidth  = el.Get <int>("TilesetWidth");
            api.tilesetHeight = el.Get <int>("TilesetHeight");
            api.tilesetSize   = el.Get <Vector2>("TilesetSize");
        }

        api.source  = (OnlineMapsSource)el.Get <int>("Source");
        api.mapType = el.Get("MapType");
        OnlineMapsProvider.MapType activeType = OnlineMapsProvider.FindMapType(api.mapType);
        if (activeType.isCustom)
        {
            api.customProviderURL = el.Get <string>("CustomProviderURL");
        }
        api.labels                   = el.Get <bool>("Labels");
        api.traffic                  = el.Get <bool>("Traffic");
        api.redrawOnPlay             = el.Get <bool>("RedrawOnPlay");
        api.useSmartTexture          = el.Get <bool>("UseSmartTexture");
        api.emptyColor               = el.Get <Color>("EmptyColor");
        api.defaultTileTexture       = GetObject(el.Get <int>("DefaultTileTexture")) as Texture2D;
        api.tooltipBackgroundTexture = GetObject(el.Get <int>("TooltipTexture")) as Texture2D;
        api.defaultMarkerTexture     = GetObject(el.Get <int>("DefaultMarkerTexture")) as Texture2D;
        api.defaultMarkerAlign       = (OnlineMapsAlign)el.Get <int>("DefaultMarkerAlign");
        api.showMarkerTooltip        = (OnlineMapsShowMarkerTooltip)el.Get <int>("ShowMarkerTooltip");
        api.useSoftwareJPEGDecoder   = el.Get <bool>("UseSoftwareJPEGDecoder");
    }
Exemplo n.º 21
0
    private static void LoadLocationService(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsLocationService ls = api.GetComponent <OnlineMapsLocationService>();

        ls.desiredAccuracy            = el.Get <float>("DesiredAccuracy");
        ls.updatePosition             = el.Get <bool>("UpdatePosition");
        ls.createMarkerInUserPosition = el.Get <bool>("CreateMarkerInUserPosition");
        ls.restoreAfter = el.Get <int>("RestoreAfter");

        if (ls.createMarkerInUserPosition)
        {
            ls.markerType = (OnlineMapsLocationServiceMarkerType)el.Get <int>("MarkerType");

            if (ls.markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                ls.marker2DTexture = GetObject(el.Get <int>("Marker2DTexture")) as Texture2D;
                ls.marker2DAlign   = (OnlineMapsAlign)el.Get <int>("Marker2DAlign");
            }
            else
            {
                ls.marker3DPrefab = GetObject(el.Get <int>("Marker3DPrefab")) as GameObject;
            }

            ls.markerTooltip       = el.Get <string>("MarkerTooltip");
            ls.useCompassForMarker = el.Get <bool>("UseCompassForMarker");
        }

        ls.useGPSEmulator = el.Get <bool>("UseGPSEmulator");
        if (ls.useGPSEmulator)
        {
            ls.emulatorPosition = el.Get <Vector2>("EmulatorPosition");
            ls.emulatorCompass  = el.Get <float>("EmulatorCompass");
        }
    }
Exemplo n.º 22
0
        public OnlineMapsUpdateItem(OnlineMapsXML node)
        {
            version = node.Get<string>("Version");
            type = node.Get<int>("Type");
            changelog = node.Get<string>("ChangeLog");
            download = node.Get<string>("Download");
            date = node.Get<string>("Date");

            string[] vars = version.Split(new[] { '.' });
            string[] vars2 = new string[4];
            vars2[0] = vars[0];
            vars2[1] = int.Parse(vars[1].Substring(0, 2)).ToString();
            vars2[2] = int.Parse(vars[1].Substring(2, 2)).ToString();
            vars2[3] = int.Parse(vars[1].Substring(4, 4)).ToString();
            version = string.Join(".", vars2);
        }
    public OnlineMapsGetElevationResult(OnlineMapsXML node)
    {
        elevation = node.Get<float>("elevation");
        resolution = node.Get<float>("resolution");

        OnlineMapsXML locationNode = node["location"];
        location = new Vector2(locationNode.Get<float>("lng"), locationNode.Get<float>("lat"));
    }
 /// <summary>
 /// Constructor of OnlineMapsFindAutocompleteResultTerm.
 /// </summary>
 /// <param name="node">Term node from response.</param>
 public OnlineMapsFindAutocompleteResultTerm(OnlineMapsXML node)
 {
     try
     {
         value = node.Get<string>("value");
         offset = node.Get<int>("height");
     }
     catch (Exception)
     {
     }
 }
 /// <summary>
 /// Constructor of OnlineMapsFindAutocompleteResultMatchedSubstring.
 /// </summary>
 /// <param name="node">MatchedSubstring node from response.</param>
 public OnlineMapsFindAutocompleteResultMatchedSubstring(OnlineMapsXML node)
 {
     try
     {
         length = node.Get<int>("length");
         offset = node.Get<int>("height");
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 26
0
    private static void LoadSettings(OnlineMapsXML el, OnlineMaps api)
    {
        api.position = el.Get<Vector2>("Position");
        api.zoom = el.Get<int>("Zoom");

        if (api.target == OnlineMapsTarget.texture)
        {
            api.texture = GetObject(el.Get<int>("Texture")) as Texture2D;
        }
        else
        {
            api.tilesetWidth = el.Get<int>("TilesetWidth");
            api.tilesetHeight = el.Get<int>("TilesetHeight");
            api.tilesetSize = el.Get<Vector2>("TilesetSize");
        }

        api.source = (OnlineMapsSource) el.Get<int>("Source");
        api.provider = (OnlineMapsProviderEnum) el.Get<int>("Provider");
        if (api.provider == OnlineMapsProviderEnum.custom) api.customProviderURL = el.Get<string>("CustomProviderURL");
        api.type = el.Get<int>("Prefs");
        api.labels = el.Get<bool>("Labels");
        api.traffic = el.Get<bool>("Traffic");
        api.redrawOnPlay = el.Get<bool>("RedrawOnPlay");
        api.useSmartTexture = el.Get<bool>("UseSmartTexture");
        api.emptyColor = el.Get<Color>("EmptyColor");
        api.defaultTileTexture = GetObject(el.Get<int>("DefaultTileTexture")) as Texture2D;
        api.skin = GetObject(el.Get<int>("Skin")) as GUISkin;
        api.defaultMarkerTexture = GetObject(el.Get<int>("DefaultMarkerTexture")) as Texture2D;
        api.defaultMarkerAlign = (OnlineMapsAlign) el.Get<int>("DefaultMarkerAlign");
        api.showMarkerTooltip = (OnlineMapsShowMarkerTooltip) el.Get<int>("ShowMarkerTooltip");
        api.useSoftwareJPEGDecoder = el.Get<bool>("UseSoftwareJPEGDecoder");
    }
Exemplo n.º 27
0
    private static void LoadLocationService(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsLocationService ls = api.GetComponent<OnlineMapsLocationService>();
        ls.desiredAccuracy = el.Get<float>("DesiredAccuracy");
        ls.updatePosition = el.Get<bool>("UpdatePosition");
        ls.createMarkerInUserPosition = el.Get<bool>("CreateMarkerInUserPosition");
        ls.restoreAfter = el.Get<int>("RestoreAfter");

        if (ls.createMarkerInUserPosition)
        {
            ls.markerType = (OnlineMapsLocationServiceMarkerType) el.Get<int>("MarkerType");

            if (ls.markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                ls.marker2DTexture = GetObject(el.Get<int>("Marker2DTexture")) as Texture2D;
                ls.marker2DAlign = (OnlineMapsAlign) el.Get<int>("Marker2DAlign");
            }
            else ls.marker3DPrefab = GetObject(el.Get<int>("Marker3DPrefab")) as GameObject;

            ls.markerTooltip = el.Get<string>("MarkerTooltip");
            ls.useCompassForMarker = el.Get<bool>("UseCompassForMarker");
        }

        ls.useGPSEmulator = el.Get<bool>("UseGPSEmulator");
        if (ls.useGPSEmulator)
        {
            ls.emulatorPosition = el.Get<Vector2>("EmulatorPosition");
            ls.emulatorCompass = el.Get<float>("EmulatorCompass");
        }
    }
    /// <summary>
    /// Constructor of OnlineMapsFindPlaceDetailsResult.
    /// </summary>
    /// <param name="node">Place node from response.</param>
    public OnlineMapsFindPlaceDetailsResult(OnlineMapsXML node)
    {
        this.node = node;
        formatted_address = node.Get("formatted_address");
        formatted_phone_number = node.Get("formatted_phone_number");

        OnlineMapsXML locationNode = node.Find("geometry/location");
        if (!locationNode.isNull) location = new Vector2(locationNode.Get<float>("lng"), locationNode.Get<float>("lat"));

        icon = node.Get("icon");
        id = node.Get("id");
        international_phone_number = node.Get("international_phone_number");
        name = node.Get("name");

        OnlineMapsXMLList photosList = node.FindAll("photos");
        photos = new OnlineMapsFindPlacesResultPhoto[photosList.count];
        for (int i = 0; i < photosList.count; i++) photos[i] = new OnlineMapsFindPlacesResultPhoto(photosList[i]);

        place_id = node.Get<string>("place_id");
        price_level = node.Get("price_level", -1);
        rating = node.Get<float>("rating");
        reference = node.Get("reference");

        OnlineMapsXMLList typeNode = node.FindAll("type");
        types = new string[typeNode.count];
        for (int i = 0; i < typeNode.count; i++) types[i] = typeNode[i].Value();

        url = node.Get("url");
        utc_offset = node.Get("utc_offset");
        vicinity = node.Get("vicinity");
        website = node.Get("website");
    }
Exemplo n.º 29
0
    public static Vector2 GetLatLng(this OnlineMapsXML node, string subNodeName)
    {
        OnlineMapsXML subNode = node[subNodeName];

        return(new Vector2(subNode.Get <float>("lng"), subNode.Get <float>("lat")));
    }
 /// <summary>
 /// Converts XMLNode coordinates from Google Maps into Vector2.
 /// </summary>
 /// <param name="node">XMLNode coordinates from Google Maps.</param>
 /// <returns>Coordinates as Vector2.</returns>
 public static Vector2 GetVector2FromNode(OnlineMapsXML node)
 {
     float lng = node.Get<float>("lng");
     float lat = node.Get<float>("lat");
     return new Vector2(lng, lat);
 }