public FedExLocator(string zipCode) { InitializeComponent(); SearchLocationsResponse locsResp = GetFedExLocations(zipCode); if (locsResp.GeoMapLocations.Count > 0) { fedExLocatorMap.Focus(); AddPushpins(locsResp); GeoMapLocation firstLoc = locsResp.GeoMapLocations.First(); Location center = new Location(firstLoc.Latitude, firstLoc.Longitude); fedExLocatorMap.SetView(center, 12); // zoom in to first location } else { MessageBox.Show("Unable to find any FedEx location. \nPlease try another ZIP code."); } }
private string ComposeAddress(GeoMapLocation loc) { Address addr = loc.LocationInfo.LocationContactAndAddress.Address; string streetStr = ""; if (addr.StreetLines.Length > 0) { for (int i = 0; i < addr.StreetLines.Length; i++) { streetStr += addr.StreetLines[i] + "\n"; } } string addressStr = streetStr + addr.City + "\n" + addr.StateOrProvinceCode + "\n" + addr.PostalCode + "\n" + addr.CountryCode + "\n"; return(addressStr); }
/// <summary> /// Show the geo map location of an item /// </summary> private void SetGeoMapLocation(GeoMapLocation Location, int LayerItem = 1) { if (Location.Latitude == 0 && Location.Longitude == 0) return; //GMapToolTip objToolTip; //objToolTip.Font = Font.; //objToolTip //ToolTip objToolTip = new ToolTip(); //objToolTip.ToolTipIcon = ToolTipIcon.Info; //objToolTip m_objPosition = new PointLatLng(Location.Latitude, Location.Longitude); m_objMarker = new GMap.NET.WindowsForms.Markers.GMapMarkerGoogleRed(m_objPosition); m_objMarker.ToolTipText = Location.Tooltip; m_objMarker.ToolTipMode = MarkerTooltipMode.Always; //m_objMarker.ToolTip = objToolTip; m_objOverlay = new GMapOverlay(gMapControl, "Layer_" + LayerItem.ToString()); m_objOverlay.Markers.Add(m_objMarker); gMapControl.Overlays.Add(m_objOverlay); if (LayerItem == 1) { gMapControl.Position = new PointLatLng(Location.Latitude, Location.Longitude); m_DefaultLatitude = Location.Latitude; m_DefaultLongitude = Location.Longitude; } }
/// <summary> /// Focus on a specific location in zoomed state /// </summary> /// <param name="Location"></param> public void Show(GeoMapLocation Location) { gMapControl.Position = new PointLatLng(Location.Latitude, Location.Longitude); gMapControl.Zoom = 12; }
/// <summary> /// Set a specific map location /// </summary> /// <param name="Location"></param> public void SetGeoMapLocation(GeoMapLocation Location) { this.SetGeoMapLocation(Location, 1); }
/// <summary> /// Show the geo map location for a set of items for a specified range from the point of location /// </summary> /// <param name="Locations"></param> /// <param name="PointOfLocation"></param> /// <param name="DistanceRange">Distance in kilometers</param> public void SetGeoMapLocation(List<GeoMapLocation> Locations, GeoMapLocation PointOfLocation, double DistanceRange) { this.ClearMarkers(); if (Locations != null) { int LayerItem = 0; foreach (GeoMapLocation Item in Locations) { if (this.GetDistance(PointOfLocation.Latitude, PointOfLocation.Longitude, Item.Latitude, Item.Longitude) <= DistanceRange) this.SetGeoMapLocation(Item, LayerItem += 1); } } else this.ResetDefaultCoordinates(); }