예제 #1
0
        public static route getRoute(point from, point to)
        {
            route r = new route();

            r.duration = r.distance = 0;
            modifiedRoute mr = new modifiedRoute();

            mr.from = from;
            mr.to   = to;
            Task t = Task.Factory.StartNew(delegate { Amap.getRoute(ref mr); });

            try
            {
                t.Wait(500);
                if (t.IsCompleted)
                {
                    r.distance = mr.distance;
                    r.duration = mr.duration;
                }
            }
            catch (Exception)
            {
                return(r);
            }
            finally
            {
                GC.Collect();
            }
            return(r);
        }
예제 #2
0
        public static point getPointByName(string name)
        {
            point p = new point();

            p.lat = 0;
            p.lon = 0;
            try
            {
                name = extractAddress(name);
                modifiedPoint mp = new modifiedPoint();
                mp.str = name;
                Task t = Task.Factory.StartNew(delegate { Amap.getPointByName(ref mp); });
                t.Wait(400);
                if (t.IsCompleted)
                {
                    p.lat = mp.lat;
                    p.lon = mp.lon;
                }
            }
            catch (Exception)
            {
                return(p);
            }
            finally
            {
                GC.Collect();
            }
            return(p);
        }