예제 #1
0
        public void getDirections(string options)
        {
            GetDirectionsOptions directionOptions = JSON.JsonHelper.Deserialize <GetDirectionsOptions>(options);

            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();

            // You can specify a label and a geocoordinate for the end point.
            if (directionOptions.Start != null)
            {
                LabeledMapLocation startLML = new LabeledMapLocation();
                startLML.Location = new GeoCoordinate(directionOptions.Start.Coordinates.Latitude, directionOptions.Start.Coordinates.Longitude);
                if (directionOptions.Start.Label != null)
                {
                    startLML.Label = directionOptions.Start.Label;
                }
                bingMapsDirectionsTask.Start = startLML;
            }
            // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
            if (directionOptions.End != null)
            {
                LabeledMapLocation endLML = new LabeledMapLocation();
                if (directionOptions.End.Coordinates != null)
                {
                    endLML.Location = new GeoCoordinate(directionOptions.End.Coordinates.Latitude, directionOptions.End.Coordinates.Longitude);
                }
                if (directionOptions.End.Label != null)
                {
                    endLML.Label = directionOptions.End.Label;
                }
                bingMapsDirectionsTask.End = endLML;
            }

            // If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
            bingMapsDirectionsTask.Show();
        }
예제 #2
0
        public void getDirections(string options)
        {
            string[] args       = JsonHelper.Deserialize <string[]>(options);
            string   callbackId = args[1];

            GetDirectionsOptions directionOptions = JsonHelper.Deserialize <GetDirectionsOptions>(args[0]);

            BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();

            // You can specify a label and a geocoordinate for the end point.
            if (directionOptions.Start != null)
            {
                LabeledMapLocation startLML = new LabeledMapLocation();
                if (directionOptions.Start.Coordinates != null)
                {
                    startLML.Location = new GeoCoordinate(directionOptions.Start.Coordinates.Latitude, directionOptions.Start.Coordinates.Longitude);
                }
                if (directionOptions.Start.Label != null)
                {
                    startLML.Label = directionOptions.Start.Label;
                }
                bingMapsDirectionsTask.Start = startLML;
            }
            // If you set the geocoordinate parameter to null, the label parameter is used as a search term.
            if (directionOptions.End != null)
            {
                LabeledMapLocation endLML = new LabeledMapLocation();
                if (directionOptions.End.Coordinates != null)
                {
                    endLML.Location = new GeoCoordinate(directionOptions.End.Coordinates.Latitude, directionOptions.End.Coordinates.Longitude);
                }
                if (directionOptions.End.Label != null)
                {
                    endLML.Label = directionOptions.End.Label;
                }
                bingMapsDirectionsTask.End = endLML;
            }

            // If bingMapsDirectionsTask.Start is not set, the user's current location is used as the start point.
            bingMapsDirectionsTask.Show();
            DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
        }