public SCMap AddOpenStreetSearchLayer(string search, OpenStreetSearchLayerOptions options = null)
        {
            options ??= new OpenStreetSearchLayerOptions();

            SearchBoundingBox boundingBox = null;

            if (options.BoundingBox != null && options.BoundingBox.Length > 0 && options.BoundingBox.Length != 4)
            {
                throw new Exception("Invalid bounding box. Shall be a double array with 4 elements.");
            }

            if (options.BoundingBox != null && options.BoundingBox.Length == 4)
            {
                boundingBox = new SearchBoundingBox(options.BoundingBox[0], options.BoundingBox[1], options.BoundingBox[2], options.BoundingBox[3]);
            }

            var provider = new OsmSearchDataProvider()
            {
                GenerateLayerItems    = true,
                MaxVisibleResultCount = options.ResultCount,
                ResultsCount          = options.ResultCount,
                ProcessMouseEvents    = false
            };

            options.CreateLayer(this, provider);

            provider.Search(search, options.Culture, options.CountryCodes, boundingBox, options.ResultCount);

            return(this);
        }
Ejemplo n.º 2
0
        void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e)
        {
            SearchBoundingBox bBox = e.CalculationResult.RouteResults[0].BoundingBox;

            mapControl.ZoomToRegion(new GeoPoint(bBox.NorthLatitude, bBox.WestLongitude), new GeoPoint(bBox.SouthLatitude, bBox.EastLongitude), 0.4);
            splashScreenManager.CloseWaitForm();
        }
        public void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e)
        {
            SearchBoundingBox box     = e.CalculationResult.RouteResults[0].BoundingBox;
            GeoPoint          topleft = new GeoPoint
            {
                Latitude  = box.NorthLatitude,
                Longitude = box.WestLongitude,
            };
            GeoPoint bottomRight = new GeoPoint
            {
                Latitude  = box.SouthLatitude,
                Longitude = box.EastLongitude,
            };

            //Add devpress.map.core.dll
            mapControl1.ZoomToRegion(topleft, bottomRight, 0.4);
            RouteCalculationResult result = e.CalculationResult;

            if ((result.RouteResults != null) & (result.ResultCode == RequestResultCode.Success))
            {
                for (int rnum = 0; rnum < e.CalculationResult.RouteResults.Count; rnum++)
                {
                    if (e.CalculationResult.RouteResults[rnum].Legs != null)
                    {
                        //int legNum = 1;
                        foreach (BingRouteLeg leg in e.CalculationResult.RouteResults[rnum].Legs)
                        {
                            list.Add(float.Parse(leg.Distance.ToString("0.00")));
                        }
                    }
                }
            }
        }
        public override InformationDataProviderBase CreateDataProvider(InformationLayer layer, string search, int resultCount)
        {
            GeoPoint anchorPoint = null;

            if (AnchorPoint != null && AnchorPoint.Length > 0 && AnchorPoint.Length != 2)
            {
                throw new Exception("Invalid anchor point. Shall be a double array with 2 elements.");
            }

            if (AnchorPoint != null && AnchorPoint.Length == 2)
            {
                anchorPoint = new GeoPoint(AnchorPoint[0], AnchorPoint[1]);
            }

            SearchBoundingBox boundingBox = null;

            if (BoundingBox != null && BoundingBox.Length > 0 && BoundingBox.Length != 4)
            {
                throw new Exception("Invalid bounding box. Shall be a double array with 4 elements.");
            }

            if (BoundingBox != null && BoundingBox.Length == 4)
            {
                boundingBox = new SearchBoundingBox(BoundingBox[0], BoundingBox[1], BoundingBox[2], BoundingBox[3]);
            }

            var provider = new BingSearchDataProvider()
            {
                BingKey               = Parameters.BingMapKey,
                ConnectionProtocol    = ConnectionProtocol.Https,
                GenerateLayerItems    = true,
                MaxVisibleResultCount = resultCount,
                ProcessMouseEvents    = false
            };

            provider.SearchOptions.ResultsCount = resultCount;

            layer.DataProvider = provider;

            /*
             * var completion = new TaskCompletionSource<InformationDataProviderBase>();
             *
             * provider.SearchCompleted += (s, e) =>
             * {
             *      completion.SetResult(provider);
             * };
             */

            provider.Search(search, Culture, anchorPoint, boundingBox);

            //return completion.Task.Result;
            return(provider);
        }
        void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e)
        {
            SearchBoundingBox box     = e.CalculationResult.RouteResults[0].BoundingBox;
            GeoPoint          topLeft = new GeoPoint {
                Latitude  = box.NorthLatitude,
                Longitude = box.WestLongitude
            };
            GeoPoint bottomRight = new GeoPoint {
                Latitude  = box.SouthLatitude,
                Longitude = box.EastLongitude
            };

            mapControl.ZoomToRegion(topLeft, bottomRight, 0.4);
            splashScreenManager1.CloseWaitForm();
        }
Ejemplo n.º 6
0
        private void OnRouteCalculated(object sender, BingRouteCalculatedEventArgs e)
        {
            SearchBoundingBox box     = e.CalculationResult.RouteResults[0].BoundingBox;
            GeoPoint          topLeft = new GeoPoint {
                Latitude  = box.NorthLatitude,
                Longitude = box.WestLongitude
            };
            GeoPoint bottomRight = new GeoPoint {
                Latitude  = box.SouthLatitude,
                Longitude = box.EastLongitude
            };

            mapControl.ZoomToRegion(topLeft, bottomRight, 0.4);
            waitIndicator.DeferedVisibility = false;
        }
        public SCMap AddBingSearchLayer(string search, BingSearchLayerOptions options = null)
        {
            options ??= new BingSearchLayerOptions();

            GeoPoint anchorPoint = null;

            if (options.AnchorPoint != null && options.AnchorPoint.Length > 0 && options.AnchorPoint.Length != 2)
            {
                throw new Exception("Invalid anchor point. Shall be a double array with 2 elements.");
            }

            if (options.AnchorPoint != null && options.AnchorPoint.Length == 2)
            {
                anchorPoint = new GeoPoint(options.AnchorPoint[0], options.AnchorPoint[1]);
            }

            SearchBoundingBox boundingBox = null;

            if (options.BoundingBox != null && options.BoundingBox.Length > 0 && options.BoundingBox.Length != 4)
            {
                throw new Exception("Invalid bounding box. Shall be a double array with 4 elements.");
            }

            if (options.BoundingBox != null && options.BoundingBox.Length == 4)
            {
                boundingBox = new SearchBoundingBox(options.BoundingBox[0], options.BoundingBox[1], options.BoundingBox[2], options.BoundingBox[3]);
            }

            var provider = new BingSearchDataProvider()
            {
                BingKey               = Parameters.BingMapKey,
                ConnectionProtocol    = ConnectionProtocol.Https,
                GenerateLayerItems    = true,
                MaxVisibleResultCount = options.ResultCount,
                ProcessMouseEvents    = false
            };

            provider.SearchOptions.ResultsCount = options.ResultCount;

            options.CreateLayer(this, provider);

            provider.Search(search, options.Culture, anchorPoint, boundingBox);

            return(this);
        }
Ejemplo n.º 8
0
        public override InformationDataProviderBase CreateDataProvider(InformationLayer layer, string search, int resultCount)
        {
            SearchBoundingBox boundingBox = null;

            if (BoundingBox != null && BoundingBox.Length > 0 && BoundingBox.Length != 4)
            {
                throw new Exception("Invalid bounding box. Shall be a double array with 4 elements.");
            }

            if (BoundingBox != null && BoundingBox.Length == 4)
            {
                boundingBox = new SearchBoundingBox(BoundingBox[0], BoundingBox[1], BoundingBox[2], BoundingBox[3]);
            }

            var provider = new OsmSearchDataProvider()
            {
                GenerateLayerItems    = true,
                MaxVisibleResultCount = resultCount,
                ResultsCount          = resultCount,
                ProcessMouseEvents    = false
            };

            layer.DataProvider = provider;

            /*
             * var completion = new TaskCompletionSource<InformationDataProviderBase>();
             *
             * provider.SearchCompleted += (s, e) =>
             * {
             *      completion.SetResult(provider);
             * };
             */

            provider.Search(search, Culture, CountryCodes, boundingBox, resultCount);

            //return completion.Task.Result;

            return(provider);
        }