Пример #1
0
        public override void ReceivedData(NSData data, WebDataSource dataSource)
        {
            LocationIsValid = false;

            try {
                var handle = long.Parse(data.ToString());
                var obj    = ObjectCache.Shared.GetObject(handle);
                if (obj == null)
                {
                    return;
                }

                Polyline = obj as ChangeableWrapper <GeoPolyline>;
                if (Polyline != null)
                {
                    Location        = Polyline.Value.Points?.FirstOrDefault();
                    LocationIsValid = true;
                    return;
                }

                Location = obj as GeoLocation;
                if (Location != null)
                {
                    LocationIsValid = true;
                }
            } catch (Exception e) {
                Log.Error("XIMapViewWebDocumentRepresentation", e);
                return;
            }
        }
        void AddLocationAnnotation(
            CLLocationCoordinate2D coordinate,
            ChangeableWrapper <GeoPolyline> polyline = null,
            int index = 0)
        {
            var locationStr = ToLatLonString(
                coordinate.Latitude,
                coordinate.Longitude);
            var annotation = new PolylinePointAnnotation {
                Title      = locationStr,
                Coordinate = coordinate,
                Polyline   = polyline,
                Index      = index,
            };

            mapView.AddAnnotation(annotation);
            mapView.SelectAnnotation(annotation, animated: true);
        }
Пример #3
0
        void AppendMapFrame(HtmlElement container)
        {
            var loadingDiv = Document.CreateElement(
                "div",
                "loader");

            container.AppendChild(loadingDiv);

            var iframe = Document.CreateElement("iframe");

            iframe.SetAttribute("frameborder", "0");  // Needed for IE

            iframe.AddEventListener("load", ev => container.RemoveChild(loadingDiv));

            long cacheHandle;

            if (polyline != null)
            {
                var wrapper = new ChangeableWrapper <GeoPolyline> (
                    polyline,
                    RenderState.RemoteMember != null
                    );
                wrapper.PropertyChanged += OnPolylineChanged;
                cacheHandle              = ObjectCache.Shared.GetHandle(wrapper);
            }
            else
            {
                cacheHandle = ObjectCache.Shared.GetHandle(location);
            }

            iframe.SetAttribute(
                "src",
                $"data:application/x-inspector-map-view,{cacheHandle}"
                );

            container.AppendChild(iframe);
        }