/// <summary>
    /// Constructor. \n
    /// <strong>Please do not use. </strong>\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);
    }
        /// <summary>
        /// Saves markers to PlayerPrefs as xml string
        /// </summary>
        private static void SaveMarkers()
        {
            // Create XMLDocument and first child
            OnlineMapsXML xml = new OnlineMapsXML("Markers");

            // Appands markers
            foreach (OnlineMapsMarker3D marker in OnlineMapsControlBase3D.instance.markers3D)
            {
                // Create marker node
                xml.Create("Marker", marker.position);
            }

            // Save xml string
            PlayerPrefs.SetString(prefsKey, xml.outerXml);
            PlayerPrefs.Save();
        }
    /// <summary>
    /// Converts the route obtained by OnlineMapsFindDirection, a list of the steps of the route.
    /// </summary>
    /// <param name="route">Route obtained by OnlineMapsFindDirection.</param>
    /// <returns>List of OnlineMapsDirectionStep or null.</returns>
    public static List <OnlineMapsDirectionStep> TryParse(string route)
    {
        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(route);

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

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

            OnlineMapsXMLList legNodes = direction.FindAll("route/leg");
            if (legNodes == null || legNodes.count == 0)
            {
                return(null);
            }

            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);
                }
            }

            return(steps);
        }
        catch { }

        return(null);
    }
Пример #4
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;
        }
    }
Пример #5
0
    /// <summary>
    /// Gets the coordinates of the first results from OnlineMapsFindLocation result.
    /// </summary>
    /// <param name="response">XML string. The result of the search location.</param>
    /// <returns>Coordinates - if successful, Vector2.zero - if failed.</returns>
    public static Vector2 GetCoordinatesFromResult(string response)
    {
        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(response);

            OnlineMapsXML location = xml.Find("//geometry/location");
            if (location.isNull)
            {
                return(Vector2.zero);
            }

            return(GetVector2FromNode(location));
        }
        catch { }
        return(Vector2.zero);
    }
Пример #6
0
    private static void LoadMarkers3D(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase3D   control = api.GetComponent <OnlineMapsControlBase3D>();
        List <OnlineMapsMarker3D> markers = new List <OnlineMapsMarker3D>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker3D marker = new OnlineMapsMarker3D();
            marker.position = m.Get <Vector2>("Position");
            marker.range    = m.Get <OnlineMapsRange>("Range");
            marker.label    = m.Get <string>("Label");
            marker.prefab   = GetObject(m.Get <int>("Prefab")) as GameObject;
            marker.rotation = Quaternion.Euler(m.Get <Vector3>("Rotation"));
            markers.Add(marker);
        }
        control.markers3D = markers.ToArray();
    }
    /// <summary>
    /// Load GPX Object from string.
    /// </summary>
    /// <param name="content">A string containing GPX content.</param>
    /// <returns>Instance of GPX Object</returns>
    public static OnlineMapsGPXObject Load(string content)
    {
        OnlineMapsGPXObject instance = new OnlineMapsGPXObject();

        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(content);

            instance.version = xml.A("version");
            instance.creator = xml.A("creator");

            foreach (OnlineMapsXML n in xml)
            {
                if (n.name == "wpt")
                {
                    instance.waypoints.Add(new Waypoint(n));
                }
                else if (n.name == "rte")
                {
                    instance.routes.Add(new Route(n));
                }
                else if (n.name == "trk")
                {
                    instance.tracks.Add(new Track(n));
                }
                else if (n.name == "metadata")
                {
                    instance.metadata = new Meta(n);
                }
                else if (n.name == "extensions")
                {
                    instance.extensions = n;
                }
                else
                {
                    Debug.Log(n.name);
                }
            }
        }
        catch (Exception exception)
        {
            Debug.Log(exception.Message + "\n" + exception.StackTrace);
        }

        return(instance);
    }
 /// <summary>
 /// Creates instance and loads the data from the node.
 /// </summary>
 /// <param name="node">Track node</param>
 public Track(OnlineMapsXML node) : this()
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "name")
         {
             name = n.Value();
         }
         else if (n.name == "cmt")
         {
             comment = n.Value();
         }
         else if (n.name == "desc")
         {
             description = n.Value();
         }
         else if (n.name == "src")
         {
             source = n.Value();
         }
         else if (n.name == "link")
         {
             links.Add(new Link(n));
         }
         else if (n.name == "number")
         {
             number = n.Value <uint>();
         }
         else if (n.name == "type")
         {
             type = n.Value();
         }
         else if (n.name == "trkseg")
         {
             segments.Add(new TrackSegment(n));
         }
         else if (n.name == "extensions")
         {
             extensions = n;
         }
         else
         {
             Debug.Log(n.name);
         }
     }
 }
 /// <summary>
 /// Creates instance and loads the data from the node.
 /// </summary>
 /// <param name="node">Meta node</param>
 public Meta(OnlineMapsXML node) : this()
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "name")
         {
             name = n.Value();
         }
         else if (n.name == "desc")
         {
             description = n.Value();
         }
         else if (n.name == "author")
         {
             author = new Person(n);
         }
         else if (n.name == "copyright")
         {
             copyright = new Copyright(n);
         }
         else if (n.name == "link")
         {
             links.Add(new Link(n));
         }
         else if (n.name == "time")
         {
             time = DateTime.Parse(n.Value());
         }
         else if (n.name == "keywords")
         {
             keywords = n.Value();
         }
         else if (n.name == "bounds")
         {
             bounds = new Bounds(n);
         }
         else if (n.name == "extensions")
         {
             extensions = n;
         }
         else
         {
             Debug.Log(n.name);
         }
     }
 }
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="xml">Response XML</param>
    public OnlineMapsBingMapsElevationResult(OnlineMapsXML xml)
    {
        List<ResourceSet> rs = new List<ResourceSet>();

        foreach (OnlineMapsXML node in xml)
        {
            if (node.name == "Copyright") copyright = node.Value();
            else if (node.name == "BrandLogoUri") brandLogoUri = node.Value();
            else if (node.name == "StatusCode") statusCode = node.Value<int>();
            else if (node.name == "StatusDescription") statusDescription = node.Value();
            else if (node.name == "AuthenticationResultCode") authenticationResultCode = node.Value();
            else if (node.name == "TraceId") traceId = node.Value();
            else if (node.name == "ResourceSets") foreach (OnlineMapsXML rsNode in node) rs.Add(new ResourceSet(rsNode));
        }

        resourceSets = rs.ToArray();
    }
        public Line(OnlineMapsXML node)
        {
            List <TransitAgency> agencies = new List <TransitAgency>();

            foreach (OnlineMapsXML n in node)
            {
                if (n.name == "name")
                {
                    name = n.Value();
                }
                else if (n.name == "short_name")
                {
                    short_name = n.Value();
                }
                else if (n.name == "color")
                {
                    color = n.Value();
                }
                else if (n.name == "agency")
                {
                    agencies.Add(new TransitAgency(n));
                }
                else if (n.name == "url")
                {
                    url = n.Value();
                }
                else if (n.name == "icon")
                {
                    icon = n.Value();
                }
                else if (n.name == "text_color")
                {
                    text_color = n.Value();
                }
                else if (n.name == "vehicle")
                {
                    vehicle = new Vehicle(n);
                }
                else
                {
                    Debug.Log("Line: " + n.name + "\n" + n.outerXml);
                }
            }

            this.agencies = agencies.ToArray();
        }
 public TextValue(OnlineMapsXML node)
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "text")
         {
             text = n.Value();
         }
         else if (n.name == "value")
         {
             value = n.Value <T>();
         }
         else
         {
             Debug.Log("TextValue: " + n.name + "\n" + n.outerXml);
         }
     }
 }
 /// <summary>
 /// Creates instance and loads the data from the node.
 /// </summary>
 /// <param name="node">TrackSegment node</param>
 public TrackSegment(OnlineMapsXML node) : this()
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "trkpt")
         {
             points.Add(new Waypoint(n));
         }
         else if (n.name == "extensions")
         {
             extensions = n;
         }
         else
         {
             Debug.Log(n.name);
         }
     }
 }
 /// <summary>
 /// Converts the response string to response object.
 /// </summary>
 /// <param name="response">Response string</param>
 /// <param name="outputType">Format of response string (JSON or XML)</param>
 /// <returns>Response object</returns>
 public static OnlineMapsBingMapsElevationResult GetResult(string response, Output outputType)
 {
     try
     {
         if (outputType == Output.json)
         {
             return(OnlineMapsJSON.Deserialize <OnlineMapsBingMapsElevationResult>(response));
         }
         OnlineMapsXML xml = OnlineMapsXML.Load(response);
         if (!xml.isNull)
         {
             OnlineMapsBingMapsElevationResult result = new OnlineMapsBingMapsElevationResult(xml);
             return(result);
         }
     }
     catch {}
     return(null);
 }
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="node">Node</param>
    public OnlineMapsOSMWay(OnlineMapsXML node)
    {
        id        = node.A("id");
        _nodeRefs = new List <string>();
        tags      = new List <OnlineMapsOSMTag>();

        foreach (OnlineMapsXML subNode in node)
        {
            if (subNode.name == "nd")
            {
                _nodeRefs.Add(subNode.A("ref"));
            }
            else if (subNode.name == "tag")
            {
                tags.Add(new OnlineMapsOSMTag(subNode));
            }
        }
    }
Пример #16
0
        /// <summary>
        /// Saves markers to PlayerPrefs as xml string
        /// </summary>
        public static void SaveMarkers()
        {
            // Create XMLDocument and first child
            OnlineMapsXML xml = new OnlineMapsXML("Markers");

            // Appands markers
            foreach (OnlineMapsMarker marker in OnlineMaps.instance.markers)
            {
                // Create marker node
                OnlineMapsXML markerNode = xml.Create("Marker");
                markerNode.Create("Position", marker.position);
                markerNode.Create("Label", marker.label);
            }

            // Save xml string
            PlayerPrefs.SetString(prefsKey, xml.outerXml);
            PlayerPrefs.Save();
        }
    /// <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());
    }
Пример #18
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = m.Get <Vector2>("Position");
            marker.range    = m.Get <OnlineMapsRange>("Range");
            marker.label    = m.Get <string>("Label");
            marker.texture  = GetObject(m.Get <int>("Texture")) as Texture2D;
            marker.align    = (OnlineMapsAlign)m.Get <int>("Align");
            marker.rotation = m.Get <float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="node">Node</param>
    public OnlineMapsOSMRelation(OnlineMapsXML node)
    {
        id       = node.A("id");
        _members = new List <OnlineMapsOSMRelationMember>(16);
        tags     = new List <OnlineMapsOSMTag>(4);

        foreach (OnlineMapsXML subNode in node)
        {
            if (subNode.name == "member")
            {
                _members.Add(new OnlineMapsOSMRelationMember(subNode));
            }
            else if (subNode.name == "tag")
            {
                tags.Add(new OnlineMapsOSMTag(subNode));
            }
        }
    }
 public NameLocation(OnlineMapsXML node)
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "location")
         {
             location = OnlineMapsXML.GetVector2dFromNode(n);
         }
         else if (n.name == "name")
         {
             name = n.Value();
         }
         else
         {
             Debug.Log("NameLocation: " + n.name + "\n" + n.outerXml);
         }
     }
 }
Пример #21
0
        /// <summary>
        /// Saves markers to PlayerPrefs as xml string
        /// </summary>
        public static void SaveMarkers()
        {
            // Create XMLDocument and first child
            OnlineMapsXML xml = new OnlineMapsXML("Markers");

            // Appands markers
            foreach (OnlineMapsMarker marker in OnlineMaps.instance.markers)
            {
                // Create marker node
                OnlineMapsXML markerNode = xml.Create("Marker");
                markerNode.Create("Position", marker.position);
                markerNode.Create("Label", marker.label);
            }

            // Save xml string
            PlayerPrefs.SetString(prefsKey, xml.outerXml);
            PlayerPrefs.Save();
        }
    /// <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");
    }
    /// <summary>
    /// Constructor of OnlineMapsFindAutocompleteResult.
    /// </summary>
    /// <param name="node">Result node from response.</param>
    public OnlineMapsGooglePlacesAutocompleteResult(OnlineMapsXML node)
    {
        List <Term>   terms = new List <Term>();
        List <string> types = new List <string>();

        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "description")
            {
                description = n.Value();
            }
            else if (n.name == "type")
            {
                types.Add(n.Value());
            }
            else if (n.name == "id")
            {
                id = n.Value();
            }
            else if (n.name == "place_id")
            {
                place_id = n.Value();
            }
            else if (n.name == "reference")
            {
                reference = n.Value();
            }
            else if (n.name == "term")
            {
                terms.Add(new Term(n));
            }
            else if (n.name == "matched_substring")
            {
                matchedSubstring = new MatchedSubstring(n);
            }
            else
            {
                Debug.Log(n.name);
            }
        }

        this.terms = terms.ToArray();
        this.types = types.ToArray();
    }
    /// <summary>
    /// Converts the route obtained by OnlineMapsOpenRouteService, a list of the steps of the route.
    /// </summary>
    /// <param name="route">Route obtained by OnlineMapsOpenRouteService.</param>
    /// <returns>List of OnlineMapsDirectionStep or null.</returns>
    public static List <OnlineMapsDirectionStep> TryParseORS(string route)
    {
        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(route);
            OnlineMapsXMLNamespaceManager nsmgr = xml.GetNamespaceManager();
            OnlineMapsXML errorNode             = xml.Find("//xls:ErrorList/xls:Error", nsmgr);
            if (!errorNode.isNull)
            {
                return(null);
            }

            OnlineMapsXMLList instructionNodes   = xml.FindAll("//xls:RouteInstruction", nsmgr);
            List <OnlineMapsDirectionStep> steps = new List <OnlineMapsDirectionStep>();

            foreach (OnlineMapsXML node in instructionNodes)
            {
                OnlineMapsDirectionStep step = new OnlineMapsDirectionStep();
                step.points = new List <Vector2>();

                OnlineMapsXML geometry = node.Find("xls:RouteInstructionGeometry", nsmgr);
                OnlineMapsXML line     = geometry[0];
                foreach (OnlineMapsXML pointNode in line)
                {
                    string   coordsStr = pointNode.Value();
                    string[] coords    = coordsStr.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    Vector2  coordsV   = new Vector2(float.Parse(coords[0]), float.Parse(coords[1]));
                    step.points.Add(coordsV);
                }

                step.distance     = (int)(node.Find("xls:Distance", nsmgr).A <float>("value") * 1000);
                step.instructions = node.Find("xls:Instruction", nsmgr).Value();

                steps.Add(step);
            }

            return(steps);
        }
        catch (Exception exception)
        {
            Debug.Log("Exception: " + exception.Message + "\n" + exception.StackTrace);
        }
        return(null);
    }
Пример #25
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)
        {
        }
    }
        private void Start()
        {
            // Create a new markers.
            OnlineMapsMarker marker1 = OnlineMaps.instance.AddMarker(Vector2.zero, "Marker 1");
            OnlineMapsMarker marker2 = OnlineMaps.instance.AddMarker(new Vector2(10, 0), "Marker 2");

            // Create new XML and store it in customData.
            OnlineMapsXML xml1 = new OnlineMapsXML("MarkerData");
            xml1.Create("ID", "marker1");
            marker1.customData = xml1;

            OnlineMapsXML xml2 = new OnlineMapsXML("MarkerData");
            xml2.Create("ID", "marker2");
            marker2.customData = xml2;

            // Subscribe to click event.
            marker1.OnClick += OnMarkerClick;
            marker2.OnClick += OnMarkerClick;
        }
 /// <summary>
 /// Creates instance and loads the data from the node.
 /// </summary>
 /// <param name="node">Link node</param>
 public Link(OnlineMapsXML node)
 {
     href = node.A("href");
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "text")
         {
             text = n.Value();
         }
         else if (n.name == "type")
         {
             type = n.Value();
         }
         else
         {
             Debug.Log(n.name);
         }
     }
 }
 /// <summary>
 /// Creates instance and loads the data from the node.
 /// </summary>
 /// <param name="node">Copyright node</param>
 public Copyright(OnlineMapsXML node)
 {
     author = node.A("author");
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "year")
         {
             year = n.Value <int>();
         }
         else if (n.name == "license")
         {
             license = n.Value();
         }
         else
         {
             Debug.Log(n.name);
         }
     }
 }
Пример #29
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>
    /// Converts response into an result object.
    /// Note: The object may not contain all the available fields.\n
    /// Other fields can be obtained from OnlineMapsGooglePlaceDetailsResult.node.
    /// </summary>
    /// <param name="response">Response of Google API.</param>
    /// <returns>Result object or null.</returns>
    public static OnlineMapsGooglePlaceDetailsResult GetResult(string response)
    {
        try
        {
            OnlineMapsXML xml    = OnlineMapsXML.Load(response);
            string        status = xml.Find <string>("//status");
            if (status != "OK")
            {
                return(null);
            }

            return(new OnlineMapsGooglePlaceDetailsResult(xml["result"]));
        }
        catch
        {
        }

        return(null);
    }
 public void AppendToNode(OnlineMapsXML node)
 {
     if (!string.IsNullOrEmpty(name))
     {
         node.Create("name", name);
     }
     if (!string.IsNullOrEmpty(comment))
     {
         node.Create("cmt", comment);
     }
     if (!string.IsNullOrEmpty(description))
     {
         node.Create("desc", description);
     }
     if (!string.IsNullOrEmpty(source))
     {
         node.Create("src", source);
     }
     if (links != null)
     {
         foreach (Link l in links)
         {
             l.AppendToNode(node.Create("link"));
         }
     }
     if (number.HasValue)
     {
         node.Create("number", number.Value);
     }
     if (!string.IsNullOrEmpty(type))
     {
         node.Create("type", type);
     }
     foreach (TrackSegment p in segments)
     {
         p.AppendToNode(node.Create("trkseg"));
     }
     if (extensions != null)
     {
         node.AppendChild(extensions);
     }
 }
 public TransitDetails(OnlineMapsXML node)
 {
     foreach (OnlineMapsXML n in node)
     {
         if (n.name == "arrival_stop")
         {
             arrival_stop = new NameLocation(n);
         }
         else if (n.name == "departure_stop")
         {
             departure_stop = new NameLocation(n);
         }
         else if (n.name == "arrival_time")
         {
             arrival_time = new TextValueZone <string>(n);
         }
         else if (n.name == "departure_time")
         {
             departure_time = new TextValueZone <string>(n);
         }
         else if (n.name == "headsign")
         {
             headsign = n.Value();
         }
         else if (n.name == "headway")
         {
             headway = n.Value <int>();
         }
         else if (n.name == "num_stops")
         {
             num_stops = n.Value <int>();
         }
         else if (n.name == "line")
         {
             line = new Line(n);
         }
         else
         {
             Debug.Log("TransitDetails: " + n.name + "\n" + n.outerXml);
         }
     }
 }
 public void AppendToNode(OnlineMapsXML node)
 {
     if (!string.IsNullOrEmpty(name))
     {
         node.Create("name", name);
     }
     if (!string.IsNullOrEmpty(description))
     {
         node.Create("desc", description);
     }
     if (author != null)
     {
         author.AppendToNode(node);
     }
     if (copyright != null)
     {
         copyright.AppendToNode(node.Create("copyright"));
     }
     if (links != null && links.Count > 0)
     {
         foreach (Link l in links)
         {
             l.AppendToNode(node.Create("link"));
         }
     }
     if (time.HasValue)
     {
         node.Create("time", time.Value.ToUniversalTime().ToString("s") + "Z");
     }
     if (!string.IsNullOrEmpty(keywords))
     {
         node.Create("keywords", keywords);
     }
     if (bounds != null)
     {
         bounds.AppendToNode(node.Create("bounds"));
     }
     if (extensions != null)
     {
         node.AppendChild(extensions);
     }
 }
        /// <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);
        }
        private void SaveState()
        {
            OnlineMaps api = OnlineMaps.instance;

            OnlineMapsXML prefs = new OnlineMapsXML("Map");

            // Save position and zoom
            OnlineMapsXML generalSettings = prefs.Create("General");
            generalSettings.Create("Coordinates", api.position);
            generalSettings.Create("Zoom", api.zoom);

            // Save 2D markers
            api.SaveMarkers(prefs);

            // Save 3D markers
            api.GetComponent<OnlineMapsControlBase3D>().SaveMarkers3D(prefs);

            // Save settings to PlayerPrefs
            PlayerPrefs.SetString(key, prefs.outerXml);
        }
Пример #36
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();
        }
 public override OnlineMapsXML SaveSettings(OnlineMapsXML parent)
 {
     OnlineMapsXML element = base.SaveSettings(parent);
     element.Create("CheckMarker2DVisibility", (int) checkMarker2DVisibility);
     element.Create("SmoothZoom", smoothZoom);
     element.Create("UseElevation", useElevation);
     element.Create("TileMaterial", tileMaterial);
     element.Create("TileShader", tilesetShader);
     element.Create("DrawingShader", drawingShader);
     element.Create("MarkerMaterial", markerMaterial);
     element.Create("MarkerShader", markerShader);
     return element;
 }
 /// <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
    /// </summary>
    /// <param name="node">XML Node</param>
    /// <param name="isReverse">Indicates reverse geocoding result.</param>
    public OnlineMapsOSMNominatimResult(OnlineMapsXML node, bool isReverse)
    {
        this.node = node;

        place_id = node.A<int>("place_id");
        osm_type = node.A("osm_type");
        osm_id = node.A<int>("osm_id");
        place_rank = node.A<int>("place_rank");
        latitude = node.A<double>("lat");
        longitude = node.A<double>("lon");
        location = new Vector2((float)longitude, (float)latitude);
        display_name = isReverse? node.Value(): node.A("display_name");
        type = node.A("type");
        importance = node.A<double>("importance");

        string bb = node.A("boundingbox");
        if (!string.IsNullOrEmpty(bb))
        {
            string[] bbParts = bb.Split(',');
            double w = Double.Parse(bbParts[0]);
            double e = Double.Parse(bbParts[1]);
            double s = Double.Parse(bbParts[2]);
            double n = Double.Parse(bbParts[3]);
            boundingbox = new Rect((float)w, (float)n, (float)(e - w), (float)(s - n));
        }

        addressdetails = new Dictionary<string, string>();
    }
 public OnlineMapsXMLEnum(OnlineMapsXML el)
 {
     this.el = el;
 }
Пример #41
0
 public override OnlineMapsXML Save(OnlineMapsXML parent)
 {
     OnlineMapsXML element = base.Save(parent);
     element.Create("Prefab", prefab);
     element.Create("Rotation", rotation.eulerAngles);
     return element;
 }
 public virtual OnlineMapsXML SaveSettings(OnlineMapsXML parent)
 {
     OnlineMapsXML element = parent.Create("Control");
     element.Create("AllowAddMarkerByM", allowAddMarkerByM);
     element.Create("AllowZoom", allowZoom);
     element.Create("AllowUserControl", allowUserControl);
     element.Create("ZoomInOnDoubleClick", zoomInOnDoubleClick);
     return element;
 }
        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);
        }
Пример #44
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = m.Get<Vector2>("Position");
            marker.range = m.Get<OnlineMapsRange>("Range");
            marker.label = m.Get<string>("Label");
            marker.texture = GetObject(m.Get<int>("Texture")) as Texture2D;
            marker.align = (OnlineMapsAlign)m.Get<int>("Align");
            marker.rotation = m.Get<float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
    public OnlineMapsXML Save(OnlineMapsXML parent)
    {
        OnlineMapsXML element = parent.Create("LocationService");
        element.Create("DesiredAccuracy", desiredAccuracy);
        element.Create("UpdatePosition", updatePosition);
        element.Create("AutoStopUpdateOnInput", autoStopUpdateOnInput);
        element.Create("RestoreAfter", restoreAfter);

        element.Create("CreateMarkerInUserPosition", createMarkerInUserPosition);

        if (createMarkerInUserPosition)
        {
            element.Create("MarkerType", (int)markerType);
            
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                element.Create("Marker2DAlign", (int) marker2DAlign);
                element.Create("Marker2DTexture", marker2DTexture);
            }
            else element.Create("Marker3DPrefab", marker3DPrefab);

            element.Create("MarkerTooltip", markerTooltip);
            element.Create("UseCompassForMarker", useCompassForMarker);
        }

        element.Create("UseGPSEmulator", useGPSEmulator);
        if (useGPSEmulator)
        {
            element.Create("EmulatorPosition", emulatorPosition);
            element.Create("EmulatorCompass", emulatorCompass);
        }

        return element;
    }
Пример #46
0
    private static void LoadMarkers3D(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase3D control = api.GetComponent<OnlineMapsControlBase3D>();
        List<OnlineMapsMarker3D> markers = new List<OnlineMapsMarker3D>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker3D marker = new OnlineMapsMarker3D();
            marker.position = m.Get<Vector2>("Position");
            marker.range = m.Get<OnlineMapsRange>("Range");
            marker.label = m.Get<string>("Label");
            marker.prefab = GetObject(m.Get<int>("Prefab")) as GameObject;
            marker.rotation = Quaternion.Euler(m.Get<Vector3>("Rotation"));
            markers.Add(marker);
        }
        control.markers3D = markers.ToArray();
    }
Пример #47
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");
    }
Пример #48
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");
    }
Пример #50
0
    /// <summary>
    /// This method is for the editor. \n
    /// Please do not use it.
    /// </summary>
    /// <param name="parent">Parent XML Element</param>
    /// <returns></returns>
    public OnlineMapsXML SaveSettings(OnlineMapsXML parent)
    {
        OnlineMapsXML element = parent.Create("Settings");

        element.Create("Position", position);
        element.Create("Zoom", zoom);

        if (target == OnlineMapsTarget.texture) element.Create("Texture", texture);
        else
        {
            element.Create("TilesetWidth", tilesetWidth);
            element.Create("TilesetHeight", tilesetHeight);
            element.Create("TilesetSize", tilesetSize);
        }

        element.Create("Source", (int)source);
        element.Create("Provider", (int)provider);
        if (provider == OnlineMapsProviderEnum.custom) element.Create("CustomProviderURL", customProviderURL);
        element.Create("Type", type);
        element.Create("Labels", labels);
        element.Create("Traffic", traffic);
        element.Create("RedrawOnPlay", redrawOnPlay);
        element.Create("UseSmartTexture", useSmartTexture);
        element.Create("EmptyColor", emptyColor);
        element.Create("DefaultTileTexture", defaultTileTexture);
        element.Create("Skin", skin);
        element.Create("DefaultMarkerTexture", defaultMarkerTexture);
        element.Create("DefaultMarkerAlign", (int)defaultMarkerAlign);
        element.Create("ShowMarkerTooltip", (int)showMarkerTooltip);
        element.Create("UseSoftwareJPEGDecoder", useSoftwareJPEGDecoder);

        return element;
    }
Пример #51
0
    /// <summary>
    /// This method is for the editor. \n
    /// Please do not use it.
    /// </summary>
    /// <param name="parent">Parent XML Element</param>
    public void SaveMarkers(OnlineMapsXML parent)
    {
        if (markers == null || markers.Length == 0) return;

        OnlineMapsXML element = parent.Create("Markers");
        foreach (OnlineMapsMarker marker in markers) marker.Save(element);
    }
    public override OnlineMapsXML SaveSettings(OnlineMapsXML parent)
    {
        OnlineMapsXML element = base.SaveSettings(parent);
        element.Create("AllowAddMarker3DByN", allowAddMarker3DByN);
        element.Create("AllowCameraControl", allowCameraControl);

        if (allowCameraControl)
        {
            element.Create("CameraDistance", cameraDistance);
            element.Create("CameraRotation", cameraRotation);
            element.Create("CameraSpeed", cameraSpeed);
        }

        element.Create("Marker2DMode", (int) marker2DMode);
        element.Create("Marker2DSize", marker2DSize);
        element.Create("Marker3DScale", marker3DScale);
        element.Create("Camera", activeCamera);

        return element;
    }
    /// <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)
        {
        }
    }
 public OnlineMapsXML SaveMarkers3D(OnlineMapsXML parent)
 {
     if (markers3D == null || markers3D.Length == 0) return null;
     OnlineMapsXML element = parent.Create("Markers3D");
     foreach (OnlineMapsMarker3D marker in markers3D) marker.Save(element);
     return element;
 }
    /// <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>
    /// Constructor of OnlineMapsFindAutocompleteResult.
    /// </summary>
    /// <param name="node">Result node from response.</param>
    public OnlineMapsFindAutocompleteResult(OnlineMapsXML node)
    {
        List<OnlineMapsFindAutocompleteResultTerm> terms = new List<OnlineMapsFindAutocompleteResultTerm>();
        List<string> types = new List<string>();

        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "description") description = n.Value();
            else if (n.name == "type") types.Add(n.Value());
            else if (n.name == "id") id = n.Value();
            else if (n.name == "place_id") place_id = n.Value();
            else if (n.name == "reference") reference = n.Value();
            else if (n.name == "term") terms.Add(new OnlineMapsFindAutocompleteResultTerm(n));
            else if (n.name == "matched_substring") matchedSubstring = new OnlineMapsFindAutocompleteResultMatchedSubstring(n);
            else Debug.Log(n.name);
        }

        this.terms = terms.ToArray();
        this.types = types.ToArray();
    }
    /// <summary>
    /// Constuctor
    /// </summary>
    /// <param name="node">Node of result</param>
    public OnlineMapsBingMapsLocationResult(OnlineMapsXML node)
    {
        this.node = node;
        address = new Dictionary<string, string>();
        foreach (OnlineMapsXML n in node)
        {
            if (n.name == "Name") name = n.Value();
            else if (n.name == "Point")
            {
                latitude = n.Get<double>("Latitude");
                longitude = n.Get<double>("Longitude");
                location = new Vector2((float)longitude, (float)latitude);
            }
            else if (n.name == "BoundingBox")
            {
                double slat = n.Get<double>("SouthLatitude");
                double wlng = n.Get<double>("WestLongitude");
                double nlat = n.Get<double>("NorthLatitude");
                double elng = n.Get<double>("EastLongitude");

                boundingBox = new Rect((float)wlng, (float)nlat, (float)(wlng - elng), (float)(nlat - slat));
            }
            else if (n.name == "EntityType") entityType = n.Value();
            else if (n.name == "Address")
            {
                foreach (OnlineMapsXML an in n)
                {
                    if (an.name == "FormattedAddress") formattedAddress = an.Value();
                    else address.Add(an.name, an.Value());
                }
            }
            else if (n.name == "Confidence") confidence = n.Value();
            else if (n.name == "MatchCode") matchCode = n.Value();
        }
    }
 /// <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)
     {
     }
 }
Пример #59
0
    private void DrawSaveGUI(ref bool dirty)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        EditorGUILayout.LabelField("Save state:");

        saveSettings = EditorGUILayout.Toggle("Settings", saveSettings);

        if (allowSaveTexture) saveTexture = EditorGUILayout.Toggle("Texture", saveTexture);

        saveControl = EditorGUILayout.Toggle("Control", saveControl);
        saveMarkers = EditorGUILayout.Toggle("Markers", saveMarkers);

        if (allowSaveMarkers3D) saveMarkers3D = EditorGUILayout.Toggle("Markers 3D", saveMarkers3D);
        if (allowSaveLocationService) saveLocationService = EditorGUILayout.Toggle("Location Service", saveLocationService);

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Save state"))
        {
            if (allowSaveTexture && saveTexture)
            {
                api.Save();

                string path = AssetDatabase.GetAssetPath(api.texture);
                File.WriteAllBytes(path, api.texture.EncodeToPNG());
                AssetDatabase.Refresh();
            }

            OnlineMapsXML prefs = new OnlineMapsXML("OnlineMaps");

            if (saveSettings) api.SaveSettings(prefs);
            if (saveControl) api.GetComponent<OnlineMapsControlBase>().SaveSettings(prefs);
            if (saveMarkers) api.SaveMarkers(prefs);
            if (allowSaveMarkers3D && saveMarkers3D) api.GetComponent<OnlineMapsControlBase3D>().SaveMarkers3D(prefs);
            if (allowSaveLocationService && saveLocationService) api.GetComponent<OnlineMapsLocationService>().Save(prefs);

            OnlineMapsPrefs.Save(prefs.outerXml);

            ResetSaveSettings();
            dirty = true;
        }

        if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
        {
            ResetSaveSettings();
            dirty = true;
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();
    }
 /// <summary>
 /// Load address details.
 /// </summary>
 /// <param name="adNode">Address details XML node.</param>
 public void LoadAddressDetails(OnlineMapsXML adNode)
 {
     foreach (OnlineMapsXML n in adNode)
     {
         if (!n.isNull) addressdetails.Add(n.name, n.Value());
     }
 }