Beispiel #1
0
        /// <summary>
        /// Gets the url for a static google maps image based on the supplied map information.
        /// </summary>
        /// <param name="mapContent">Map content data.</param>
        /// <param name="languageCode">The language in which to view the map.</param>
        private static string GetStaticMapImageUrl(MapContentValue mapContent, string languageCode)
        {
            UrlBuilder url = new UrlBuilder("http://maps.google.com/maps/api/staticmap");

            url.QueryCollection["center"]      =
                url.QueryCollection["markers"] = mapContent.Latitude + "," + mapContent.Longitude;

            url.QueryCollection["zoom"]     = mapContent.Zoom.ToString();
            url.QueryCollection["size"]     = mapContent.Width + "x" + mapContent.Height;
            url.QueryCollection["sensor"]   = "false";
            url.QueryCollection["maptype"]  = mapContent.MapType;
            url.QueryCollection["language"] = languageCode;
            url.QueryCollection["key"]      = MapDynamicContentConfiguration.GoogleMapsKey;

            return((string)url);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the URL for viewing the google map described by the supplied data.
        /// </summary>
        /// <param name="mapContent">Map content data.</param>
        /// <param name="languageCode">The language in which to view the map.</param>
        private static string GetGoogleMapUrl(MapContentValue mapContent, string languageCode)
        {
            UrlBuilder url = new UrlBuilder("http://maps.google.com/maps");

            url.QueryCollection["f"]      = "d";
            url.QueryCollection["source"] = "s_q";
            url.QueryCollection["hl"]     = languageCode;
            url.QueryCollection["hnear"]  = HttpUtility.UrlEncode(mapContent.Address);
            url.QueryCollection["sll"]    = mapContent.Latitude + "," + mapContent.Longitude;
            url.QueryCollection["ie"]     = "UTF8";
            url.QueryCollection["cd"]     = "1";
            url.QueryCollection["split"]  = "0";
            url.QueryCollection["z"]      = mapContent.Zoom.ToString();

            return((string)url);
        }
Beispiel #3
0
        /// <summary>
        /// Prepares dynamic content data for save.
        /// </summary>
        public override void PrepareForSave()
        {
            MapContentValue data = new MapContentValue
            {
                Address = AddressTextBox.Text.Trim(),
                AltText = AltTextBox.Text.Trim()
            };
            int    boxValue;
            double latlngValue;

            data.Height             = Int32.TryParse(HeightTextBox.Text.Trim(), out boxValue) ? boxValue : 300;
            data.Width              = Int32.TryParse(WidthTextBox.Text.Trim(), out boxValue) ? boxValue : 300;
            data.Latitude           = double.TryParse(LatitudeField.Value.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out latlngValue) ? latlngValue : 0;
            data.Longitude          = double.TryParse(LongitudeField.Value.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out latlngValue) ? latlngValue : 0;
            data.Zoom               = Int32.TryParse(ZoomField.Value.Trim(), out boxValue) ? boxValue : 13;
            data.MapType            = MapTypeField.Value;
            data.DisplayAsStaticMap = DisplayAsStaticMapCheckBox.Checked;
            MapDynamicContent content = Content as MapDynamicContent;

            content.Value = data;
        }