Пример #1
0
        private void btnDisplayLine_Click(object sender, EventArgs e)
        {
            List<SearchLocation> locations = new List<SearchLocation>();
            foreach (string line in txtAddresses.Lines)
            {
                SearchLocation a = new SearchLocation();
                a.Where = line;  // where to search for (address)
                locations.Add(a);
            }

            ucVEarth.VE_AddShape(VE_Shape.Polyline, locations, "My Path", "A sample path", "", 10);
        }
Пример #2
0
        private void btnDisplayPolygon_Click(object sender, EventArgs e)
        {
            List<SearchLocation> locations = new List<SearchLocation>();

            if (txtAddresses.Lines.Length < 3)
            {
                MessageBox.Show("To create a polygon a minimum of 3 points is needed");
            }
            else
            {
                foreach (string line in txtAddresses.Lines)
                {
                    SearchLocation a = new SearchLocation();
                    a.Where = line;  // where to search for (address)
                    locations.Add(a);
                }

                ucVEarth.VE_AddShape(VE_Shape.Polygon, locations, "My Polygon", "A sample polygon", "", 10);
            }
        }
Пример #3
0
        /// <summary>
        /// Display pushpins for all adresses in the textbox
        /// </summary>
        private void btnDisplayAddresses_Click(object sender, EventArgs e)
        {
            // For demo pusposes, add the pushpins to a layer named "Test"
            ucVEarth.VE_AddShapeLayer("Test", "Test");

            // Create a list of locations to search for
            List<SearchLocation> locations = new List<SearchLocation>();
            foreach (string line in txtAddresses.Lines)
            {
                SearchLocation a = new SearchLocation();
                a.Where = line;  // where to search for (address)
                a.PushPinDescription = line;
                a.PushPinLayer = "Test";
                a.PushPinTitle = line;  // Title of the puspin
                locations.Add(a);
            }

            // find and display the locations, during the seacht the latitude and Longitude of each SearchLocation object is
            // set, so VEarth knows where to place the pushpins
            ucVEarth.VE_FindLocations(locations, true, true, null);
        }
Пример #4
0
        /// <summary>
        /// Get the driving directions for the adresses in the listbox (the API has a maximum of 50 addressen)
        /// </summary>
        private void btnGetDirections_Click(object sender, EventArgs e)
        {
            ucVEarth.VE_DeleteDirections();

            // Add the start and end point
            List<SearchLocation> locations = new List<SearchLocation>();
            foreach (string line in txtAddresses.Lines)
            {
                SearchLocation a = new SearchLocation();
                a.Where = line;  // where to search for (address)
                locations.Add(a);
            }
            //Clear current directions
            lvDirections.Items.Clear();

            // Get and display driving directions
            RouteDirections rd = ucVEarth.VE_GetDirections(locations, true, true, VEarth.ucVEarth.RouteModeEnum.Driving, VEarth.ucVEarth.DistanceUnitEnum.Kilometers, ucVEarth.RouteOptimizeEnum.Distance );

            lvDirections.Items.Add(String.Format("Total distance: {0}", rd.TotalDistance));
            lvDirections.Items.Add(String.Format("Total duration: {0}", GetDurationAsText(rd.TotalDuration)));
            lvDirections.Items.Add("");

            decimal totalDistance = 0;
            double totalDuration = 0;

            // Iterate through all route parts
            foreach(RouteLeg rl in rd.RouteLegs)
            {
                totalDistance += rl.Distance;
                totalDuration += rl.Duration;

                ListViewItem direction = new ListViewItem(rl.Description);
                direction.SubItems.Add(rl.Distance.ToString());
                direction.SubItems.Add(GetDurationAsText(rl.Duration));
                direction.SubItems.Add(totalDistance.ToString());
                direction.SubItems.Add(GetDurationAsText(totalDuration));
                lvDirections.Items.Add(direction);

            }
        }
Пример #5
0
 void ucVEarth_VE_OnMouseClick(double latitude, double longitude, object id, bool altKey, bool ctrlKey, bool shiftKey, bool leftButton, bool rightButton)
 {
     SearchLocation loc = new SearchLocation();
     loc.Latitude = latitude;
     loc.Longitude = longitude;
     loc.PushPinDescription = String.Format("Lat: {0}, Long: {1}", latitude, longitude);
     loc.PushPinTitle = "You've put me on the map";
     ucVEarth.VE_AddPushPin(loc);
 }
Пример #6
0
 private void PlacePictureOnMap(Picture picture)
 {
     SearchLocation a = new SearchLocation
                            {
                                Longitude = picture.GPSLongitude,
                                Latitude = picture.GPSLatitude,
                                PushPinDescription =
                                    String.Format("<IMG SRC=\"{0}\" ALT=\"{0}\" WIDTH=200 HEIGHT=200>",
                                                  picture.FileName),
                                PushPinLayer = "Photos",
                                PushPinTitle = picture.Name
                            };
     locations.Add(a);
     ucVEarth.VE_AddPushPin(a);
     ucVEarth.VE_SetCenter(a);
 }
Пример #7
0
 /// <summary>
 /// Centers the map at the specified location (based on latitude/Longitude or where/what)
 /// </summary>
 /// <param name="location">The location the map will center at</param>
 public void VE_SetCenter(SearchLocation location)
 {
     // set center by coordinates...
     if (location.Latitude != null && location.Longitude != null)
     {
         vEarthBrowser.Document.InvokeScript("setCenter",
                 new object[]
                 {
                     location.Longitude,
                     location.Latitude
                 });
     } // ...or by what / where
     else if (location.Where != String.Empty || location.What != String.Empty)
     {
         locations = new List<SearchLocation>();
         SearchLocations.Add(location);
         VE_FindLocations(locations, true, false, null);
     }
 }
Пример #8
0
        /// <summary>
        /// Add a pushpin to the map based on Latitude and Longitude coordinates
        /// </summary>
        /// <param name="location">The location and appearance of the pushpin</param>
        /// <returns>The unique identifier of the added puspin (empty when to location could not be found)</returns>
        public string VE_AddPushPin(SearchLocation location)
        {
            if (location.Latitude == null && location.Longitude == null)
            {
                throw new Exception("Specify the Latitude and Longitude of the pushpin.");
            }

            object id = vEarthBrowser.Document.InvokeScript("addPushPin",
                        new object[] {
                            location.Latitude,
                            location.Longitude,
                            location.PushPinTitle,
                            location.PushPinLayer,
                            location.PushPinImage,
                            location.PushPinDescription });

            location.ID = id == null ? "" : id.ToString();

            return location.ID;
        }