Пример #1
0
 private void UpdateBoundingBox(MFBGMapLatLon gll)
 {
     if (BoundingBox == null)
     {
         BoundingBox = new LatLongBox(gll.latlong);
     }
     else
     {
         BoundingBox.ExpandToInclude(gll.latlong);
     }
 }
Пример #2
0
        public void SetPath(IEnumerable <LatLong> rgll)
        {
            if (rgll == null)
            {
                return;
            }

            List <MFBGMapLatLon> lst = new List <MFBGMapLatLon>();

            lst.AddRange(MFBGMapLatLon.FromLatlongs(rgll));
            foreach (MFBGMapLatLon gll in lst)
            {
                UpdateBoundingBox(gll);
            }
            pathArray = lst;
        }
Пример #3
0
        /// <summary>
        /// Registers the script block that includes the data for the airports and the preferences for the map.
        /// <param name="mapID">The ID of the element on the page that holds the map</param>
        /// <param name="containerID">The client ID of the map's container</param>
        /// </summary>
        public string MapJScript(string mapID, string containerID)
        {
            Options.id           = mapID;
            Options.divContainer = containerID;

            // figure out any bounding box, adding airports, images, paths, and clubs.
            Options.BoundingBox = null;
            Options.SetAirports(Airports, AllowDupeMarkers);
            Options.SetPath(Path);
            Options.SetClubs(Clubs, ClubClickHandler);
            Options.SetImages(Images);
            Options.fAutoZoom = Options.BoundingBox != null && !Options.BoundingBox.IsEmpty;
            if (Options.BoundingBox == null)
            {
                Options.BoundingBox = new LatLongBox(new LatLong(Options.defaultLat, Options.defaultLong));
            }

            StringBuilder sbInitMap = new StringBuilder();

            // If there is a path, define a variable to hold it now.
            // We do this as an array of 2-element latitude/longitude pairs; setPath already converted the path to MFBGMapLatLong objects
            if (Path != null && Path.Any())
            {
                sbInitMap.AppendFormat(CultureInfo.InvariantCulture, "var {0} = {1};\r\n", Options.PathVarName, JsonConvert.SerializeObject(MFBGMapLatLon.AsArrayOfArrays(Options.pathArray)));
            }
            else
            {
                sbInitMap.AppendFormat(CultureInfo.InvariantCulture, "var {0} = null;\r\n", Options.PathVarName);
            }

            sbInitMap.AppendFormat(CultureInfo.InvariantCulture, @"var {0} = AddMap(new MFBNewMapOptions({1}, {2})); MFBMapsOnPage.push({0});", mapID, JsonConvert.SerializeObject(Options), Options.PathVarName);

            if (ClickHandler.Length > 0)
            {
                sbInitMap.AppendFormat(CultureInfo.InvariantCulture, "\r\n{0}.addListenerFunction({1});\r\n", mapID, ClickHandler);
            }

            return(sbInitMap.ToString());
        }