コード例 #1
0
        public void UpdatePolyLinePos(bool init, LatLng pos = null)
        {
            if (targetLine != null)
            {
                targetLine.Remove();
                targetLine.Dispose();
            }
            var polylineOptions = new PolylineOptions();

            polylineOptions.Clickable(true);
            polylineOptions.InvokeJointType(JointType.Round);//don't see the difference
            polylineOptions.InvokeWidth(10f);
            polylineOptions.InvokeColor(0x664444FF);

            int       i         = 0;
            CustomMap customMap = (CustomMap)this.Element;

            if (customMap != null)
            {
                foreach (var position in customMap.RouteCoordinates)
                {
                    if (i == 1 && !init && pos != null)
                    {
                        polylineOptions.Add(pos);
                    }
                    else
                    {
                        polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
                    }

                    i++;
                }
                targetLine = map.AddPolyline(polylineOptions);
            }
        }
コード例 #2
0
        private void PolylineDemo(HuaweiMap hMap)
        {
            hMap.Clear();

            Polyline        polyline1;
            PolylineOptions polyline1Options = new PolylineOptions()
                                               .Add(new LatLng(41.01929, 28.967267), new LatLng(41.016785, 28.986971), new LatLng(41.001917, 28.978743), new LatLng(41.002298, 28.954132));

            polyline1Options.InvokeColor(Color.Blue);
            polyline1Options.InvokeWidth(20);
            // polyline1Options.InvokeZIndex(2);
            polyline1Options.Visible(false);
            polyline1Options.Clickable(true);
            polyline1 = hMap.AddPolyline(polyline1Options);


            Polyline        polyline2;
            PolylineOptions polyline2Options = new PolylineOptions()
                                               .Add(new LatLng(41.010410, 28.978511), new LatLng(41.035243, 29.026812), new LatLng(41.022122, 29.00653), new LatLng(41.00415, 29.012449), new LatLng(41.001699, 28.978743));

            polyline2Options.InvokeColor(Color.Red);
            polyline1Options.InvokeZIndex(1);
            polyline2Options.Clickable(true);
            polyline2 = hMap.AddPolyline(polyline2Options);
        }
コード例 #3
0
        void AddPolylines(IList polylines)
        {
            var map = NativeMap;

            if (map == null)
            {
                return;
            }

            if (_polylines == null)
            {
                _polylines = new List <APolyline>();
            }

            _polylines.AddRange(polylines.Cast <Polyline>().Select(line =>
            {
                var polyline = (Polyline)line;
                var opts     = new PolylineOptions();

                foreach (var p in polyline.Positions)
                {
                    opts.Add(new LatLng(p.Latitude, p.Longitude));
                }

                opts.InvokeWidth(polyline.StrokeWidth * _scaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
                opts.InvokeColor(polyline.StrokeColor.ToAndroid());
                opts.Clickable(polyline.IsClickable);

                var nativePolyline = map.AddPolyline(opts);

                // associate pin with marker for later lookup in event handlers
                polyline.Id = nativePolyline;
                return(nativePolyline);
            }));
        }
コード例 #4
0
        protected override NativePolyline CreateNativeItem(Polyline outerItem)
        {
            var opts = new PolylineOptions();

            foreach (var p in outerItem.Positions)
            {
                opts.Add(new LatLng(p.Latitude, p.Longitude));
            }

            opts.InvokeWidth(outerItem.StrokeWidth * this.ScaledDensity); // TODO: convert from px to pt. Is this collect? (looks like same iOS Maps)
            opts.InvokeColor(outerItem.StrokeColor.ToAndroid());
            opts.Clickable(outerItem.IsClickable);
            opts.InvokeZIndex(outerItem.ZIndex);

            var nativePolyline = NativeMap.AddPolyline(opts);

            // associate pin with marker for later lookup in event handlers
            outerItem.NativeObject = nativePolyline;
            outerItem.SetOnPositionsChanged((polyline, e) =>
            {
                var native    = polyline.NativeObject as NativePolyline;
                native.Points = polyline.Positions.ToLatLngs();
            });

            return(nativePolyline);
        }
コード例 #5
0
        private void drawPolyline()
        {
            Polyline        polyline2;
            PolylineOptions polyline2Options = new PolylineOptions()
                                               .Add(new LatLng(41.03472222, 28.90027778), new LatLng(41.00166667, 28.97111111), new LatLng(41.00415, 29.012449), new LatLng(40.985996056, 29.035333192));

            polyline2Options.InvokeColor(Color.Red);
            polyline2Options.Clickable(true);
            polyline2 = hMap.AddPolyline(polyline2Options);
        }
コード例 #6
0
        private void LoadTrailPath(string start, string end, string path)
        {
            string[] pathCoords = path.Split(';');
            string[] latlng     = start.Split(',');

            double latitude  = 0;
            double longitude = 0;

            PolylineOptions lineOptions = new PolylineOptions();

            lineOptions.Clickable(true);

            latitude  = double.Parse(latlng[0]);
            longitude = double.Parse(latlng[1]);
            lineOptions.Add(new LatLng(latitude, longitude));

            //lineOptions.InvokeColor(colorList[currentColor]);

            foreach (string coord in pathCoords)
            {
                try
                {
                    latlng = coord.Split(',');

                    if (latlng.Length > 0)
                    {
                        latitude  = double.Parse(latlng[0]);
                        longitude = double.Parse(latlng[1]);

                        lineOptions.Add(new LatLng(latitude, longitude));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error translating path values: LoadTrailPath");
                    Console.WriteLine(ex.ToString());
                }
            }

            latlng    = end.Split(',');
            latitude  = double.Parse(latlng[0]);
            longitude = double.Parse(latlng[1]);
            lineOptions.Add(new LatLng(latitude, longitude));

            if (pathCoords.Length > 0)
            {
                PathList.Add(_map.AddPolyline(lineOptions));
            }
        }
コード例 #7
0
        private void addConePolyline(double angle, GeodeticCalculator geoCalculator, CustomMap customMap, LatLng userPos, double distTarget)
        {
            var polylineOptions = new PolylineOptions();

            polylineOptions.Clickable(true);
            polylineOptions.InvokeJointType(JointType.Round);
            polylineOptions.InvokeWidth(10f);
            polylineOptions.InvokeColor(0x664444FF);

            polylineOptions.Add(userPos);
            LatLng conePoint = movePoint(angle, customMap.UserPin.Position, customMap.TargetPin.Position);

            Console.WriteLine("conePoint dist = " + CustomMap.DistanceTo(customMap.UserPin.Position.Latitude, customMap.UserPin.Position.Longitude, conePoint.Latitude, conePoint.Longitude, "M"));
            polylineOptions.Add(conePoint);
            coneLines.Add(map.AddPolyline(polylineOptions));
        }