Пример #1
0
        public void Draw(Map map)
        {
            map.Dispatcher.Invoke(
                new Action(
                    async delegate
            {
                map.RemoveBehavior(Id);
                map.AddSingletonBehavior(new HitTestBehavior(Id, map, map.GetGraphicLayer(LName), Callback));

                map.GetGraphicLayer(LName).Labeling.IsEnabled = true;
                map.GetGraphicLayer(LName).AddLabel("Label");


                map.GetGraphicLayer(LName).IsCluster       = IsCluster;
                map.GetGraphicLayer(LName).ClusterDistance = 15;

                map.ClearGraphic(LName);
                foreach (Graphic g in MapPoints)
                {
                    map.AddGraphic(g, LName);
                }
                GisUtil util = new GisUtil(map);
                if (AutoZoom)
                {
                    await util.Locate(PointsEnvelope, 20);
                }
            }
                    )
                );
        }
Пример #2
0
        public Task <string> SetDataAsync(string userId, string taskGuid, string dataGuid, string dataType, string xmlData, Action <string> callback)
        {
            GisUtil util;
            var     args = new SetDataEventArgs(userId, taskGuid, dataGuid, dataType, xmlData);


            return(Task.Run(async() =>
            {
                if (!args.Valid)
                {
                    return "";
                }

                switch (args.DataType)
                {
                case "SetExtent":
                    _map.Dispatcher.Invoke(
                        new Action(
                            async delegate
                    {
                        util = new GisUtil(_map);
                        await util.Locate(args.GetDouble("//LON"), args.GetDouble("//LAT"), _map.GetScale(args.GetLong("//Level")));
                    }
                            )
                        );
                    break;

                case "LocateObject":
                    util = new GisUtil(_map);
                    QueryResult res = await util.DoQuery(args.GetString("//Service"), args.GetString("//Layer"), null, args.GetString("//Where"));
                    if (res.FeatureSet.Features.Count < 1)
                    {
                        return "";
                    }
                    _map.Dispatcher.Invoke(
                        new Action(
                            async delegate
                    {
                        _map.ClearGraphic("Highlight");
                        _map.AddGraphic(new Graphic(res.FeatureSet.Features[0].Geometry, res.FeatureSet.Features[0].Attributes), "Highlight");

                        util = new GisUtil(_map);
                        await util.Locate(res.FeatureSet.Features[0].Geometry, _map.GetScale(args.GetLong("//Level")));
                    }
                            )
                        );
                    break;

                case "LocateObjectAll":
                    util = new GisUtil(_map);
                    FindResult find = await util.DoFind(args.GetString("//Service"), null, args.GetString("//Fields"), args.GetString("//Value"));
                    if (find.Results.Count < 1)
                    {
                        return "";
                    }
                    _map.Dispatcher.Invoke(
                        new Action(
                            async delegate
                    {
                        _map.ClearGraphic("Highlight");
                        _map.AddGraphic(new Graphic(find.Results[0].Feature.Geometry, find.Results[0].Feature.Attributes), "Highlight");

                        util = new GisUtil(_map);
                        await util.Locate(find.Results[0].Feature.Geometry, _map.GetScale(args.GetLong("//Level")));
                    }
                            )
                        );
                    break;

                case "HisLocation":
                    TrackModel tm = new TrackModel(args, callback);
                    _map.SetTrack(tm);
                    break;

                case "DrawPointCollection":
                    MapPointUtil mu = new MapPointUtil(args, callback);
                    mu.Draw(_map);
                    break;
                }

                return "1";
            }));
        }