Exemple #1
0
 internal JSMapController(VELatLong center, string mapStyle, int zoomLevel, VEBirdseyeScene scene)
 {
     _events        = new Queue();
     _center        = center;
     _birdseyeScene = scene;
     _mapStyle      = mapStyle;
     _zoomLevel     = zoomLevel;
 }
 internal JSMapController(VELatLong center, string mapStyle, int zoomLevel, VEBirdseyeScene scene)
 {
     _events = new Queue();
     _center = center;
     _birdseyeScene = scene;
     _mapStyle = mapStyle;
     _zoomLevel = zoomLevel;
 }
Exemple #3
0
 public void JSUpdateBirdsEye(string sceneId,
                              string direction,
                              string sceneThumbUrl
                              )
 {
     BirdseyeScene = new VEBirdseyeScene(sceneId, direction);
     OnBirdseyeChanged(EventArgs.Empty);
 }
        public static string CreateMapUrl(string baseUrl, float latitude, float longitude, string reserved, string style, int level, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
        {
            //string queryString = String.Format(MAP_QUERY_FORMAT, latitude, longitude, level, style);

            StringBuilder sb = new StringBuilder();
            String coords = latitude.ToString(CultureInfo.InvariantCulture) + "~" + longitude.ToString(CultureInfo.InvariantCulture);
            if (reserved != null && reserved != String.Empty)
                coords = reserved;

            sb.AppendFormat(MAP_QUERY_FORMAT, coords, level, style);
            if (birdseyeScene != null)
            {
                sb.Append("&scene=");
                sb.Append(birdseyeScene.SceneId);
            }

            if (pushpins != null && pushpins.Length > 0)
            {
                sb.Append("&sp=");
                for (int i = 0; i < pushpins.Length; i++)
                {
                    VEPushpin pin = pushpins[i];
                    if (i > 0)
                    {
                        sb.Append("~");
                    }
                    sb.AppendFormat(CultureInfo.InvariantCulture, "aN.{0}_{1}_{2}_{3}", pin.VELatLong.Latitude, pin.VELatLong.Longitude, EncodeQueryValue(pin.Title), EncodeQueryValue(pin.Details));
                    if (pin.MoreInfoUrl != String.Empty || pin.PhotoUrl != String.Empty)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture, "_{0}", EncodeQueryValue(pin.MoreInfoUrl));
                        if (pin.PhotoUrl != String.Empty)
                            sb.AppendFormat(CultureInfo.InvariantCulture, "_{0}", EncodeQueryValue(pin.PhotoUrl));
                    }
                }
            }

            // ja-jp is the only non en supported market for maps, so special case it
            string cultureName = CultureInfo.CurrentUICulture.Name.ToUpperInvariant();
            if (IsSupportedLanguage(cultureName))
                sb.Append("&mkt=" + cultureName);
            else
                sb.Append("&mkt=en-us");

            string queryString = sb.ToString();

            return baseUrl + "?" + queryString;
        }
        internal static void UpdateMapImage(ISmartContent content, MapSettings settings, Size newSize)
        {
            if (settings.MapImageInvalidated)
            {
                settings.MapImageInvalidated = false;
                float           latitude   = settings.Latitude;
                float           longitude  = settings.Longitude;
                string          reserved   = settings.Reserved;
                int             zoomLevel  = settings.ZoomLevel;
                string          style      = settings.MapStyle;
                string          sceneId    = settings.BirdseyeSceneId;
                VEBirdseyeScene scene      = sceneId != null ? new VEBirdseyeScene(sceneId, settings.BirdseyeOrientation) : null;
                string          previewUrl = MapUrlHelper.CreateMapUrl(LocalMapPreviewUrl, latitude, longitude, reserved, style, zoomLevel, settings.Pushpins, scene);

#pragma warning disable 612,618
                HtmlScreenCapture screenCapture = new HtmlScreenCapture(new Uri(previewUrl, true), newSize.Width);
#pragma warning restore 612,618

                screenCapture.HtmlDocumentAvailable += new OpenLiveWriter.Api.HtmlDocumentAvailableHandler(screenCapture_HtmlDocumentAvailable);
                screenCapture.MaximumHeight          = newSize.Height;
                Bitmap bitmap = screenCapture.CaptureHtml(45000);
                if (bitmap != null)
                {
                    try
                    {
                        if (content.Files.Contains(settings.ImageFileId))
                        {
                            content.Files.Remove(settings.ImageFileId);
                        }
                    }
                    catch (Exception e) { Debug.Fail(e.ToString()); }

                    //add the new map image (note that we use a new name to a bug in IE7 that prevents the editor
                    //from refreshing the image displayed in the browser (bug 287563)
                    string newGuid        = Guid.NewGuid().ToString();
                    string newImageFileId = "map-" + newGuid.Substring(newGuid.LastIndexOf("-", StringComparison.OrdinalIgnoreCase) + 1) + ".jpg";
                    settings.ImageFileId = newImageFileId;
                    content.Files.AddImage(settings.ImageFileId, bitmap, ImageFormat.Jpeg);
                }
                else
                {
                    Debug.WriteLine("Map image could not be regenerated.");
                }
            }
        }
 public void UpdateSettings(float latitude, float longitude, string reserved, int zoomLevel, string style, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
 {
     Latitude = latitude;
     Longitude = longitude;
     Reserved = reserved;
     ZoomLevel = zoomLevel;
     MapStyle = style;
     Pushpins = pushpins;
     if (birdseyeScene != null)
     {
         BirdseyeSceneId = birdseyeScene.SceneId;
         BirdseyeOrientation = birdseyeScene.Orientation.ToString();
     }
     else
     {
         BirdseyeSceneId = null;
         BirdseyeOrientation = null;
     }
     MapImageInvalidated = true;
 }
        private void ShowCustomizeMapDialog()
        {
            using (new WaitCursor())
            {
                if (!MapForm.ValidateLiveLocalConnection(true))
                {
                    return;
                }

                using (MapForm mapForm = new MapForm(false, _mapOptions, ((ICommandManagerHost)_contentEditorSite).CommandManager))
                {
                    VEBirdseyeScene scene = null;
                    if (_mapSettings.MapStyle == "o")
                    {
                        scene = new VEBirdseyeScene(_mapSettings.BirdseyeSceneId, _mapSettings.BirdseyeOrientation);
                    }
                    mapForm.LoadMap(_mapSettings.Latitude, _mapSettings.Longitude, _mapSettings.Reserved, _mapSettings.MapStyle, _mapSettings.ZoomLevel, scene);
                    mapForm.Pushpins = _mapSettings.Pushpins;
                    if (mapForm.ShowDialog(this) == DialogResult.OK)
                    {
                        _mapOptions.DefaultDialogSize = mapForm.Size;
                        _mapSettings.UpdateSettings(mapForm.Latitude, mapForm.Longitude, mapForm.Reserved, mapForm.ZoomLevel, mapForm.MapStyle, mapForm.Pushpins, mapForm.BirdseyeScene);

                        SelectedContent.Files.Remove(_mapSettings.ImageFileId);
                        Size mapSize = _mapSettings.Size;
                        Debug.Assert(mapSize != Size.Empty);
                        MapContentSource.UpdateMapImage(SelectedContent, _mapSettings, mapSize);
                        _mapSettings.Size = mapSize;

                        sidebarHeaderControl1.LinkUrl = _mapSettings.LiveMapUrl;
                        sidebarHeaderControl1.RefreshLayout();

                        OnContentEdited();
                    }
                }
            }
        }
Exemple #8
0
 public MapActiveObject(VELatLong center, string mapStyle, int zoomLevel, VEBirdseyeScene birdseyeScene)
 {
     _jsMapController = new JSMapController(center, mapStyle, zoomLevel, birdseyeScene);
     _pushpinTable    = new Hashtable();
     _pushpinList     = new ArrayList();
 }
 public MapActiveObject(VELatLong center, string mapStyle, int zoomLevel, VEBirdseyeScene birdseyeScene)
 {
     _jsMapController = new JSMapController(center, mapStyle, zoomLevel, birdseyeScene);
     _pushpinTable = new Hashtable();
     _pushpinList = new ArrayList();
 }
        /// <summary>
        /// Initializes the map to a center on a set of coordinates.
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="mapStyle"></param>
        /// <param name="zoomLevel"></param>
        public void LoadMap(float latitude, float longitude, string reserved, string mapStyle, int zoomLevel, VEBirdseyeScene scene)
        {
            MapActiveObject = new MapActiveObject(new VELatLong(latitude, longitude, reserved), mapStyle, zoomLevel, scene);

            //string url = MapUrlHelper.CreateMapUrl(LocalMapUrl, latitude, longitude, mapStyle, zoomLevel);
            string url = LocalMapUrl;
            url = new Uri(url).ToString();
            explorerBrowserControl.Navigate(url);
        }
        public static string CreateMapUrl(string baseUrl, float latitude, float longitude, string reserved, string style, int level, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
        {
            //string queryString = String.Format(MAP_QUERY_FORMAT, latitude, longitude, level, style);

            StringBuilder sb     = new StringBuilder();
            String        coords = latitude.ToString(CultureInfo.InvariantCulture) + "~" + longitude.ToString(CultureInfo.InvariantCulture);

            if (reserved != null && reserved != String.Empty)
            {
                coords = reserved;
            }

            sb.AppendFormat(MAP_QUERY_FORMAT, coords, level, style);
            if (birdseyeScene != null)
            {
                sb.Append("&scene=");
                sb.Append(birdseyeScene.SceneId);
            }

            if (pushpins != null && pushpins.Length > 0)
            {
                sb.Append("&sp=");
                for (int i = 0; i < pushpins.Length; i++)
                {
                    VEPushpin pin = pushpins[i];
                    if (i > 0)
                    {
                        sb.Append("~");
                    }
                    sb.AppendFormat(CultureInfo.InvariantCulture, "aN.{0}_{1}_{2}_{3}", pin.VELatLong.Latitude, pin.VELatLong.Longitude, EncodeQueryValue(pin.Title), EncodeQueryValue(pin.Details));
                    if (pin.MoreInfoUrl != String.Empty || pin.PhotoUrl != String.Empty)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture, "_{0}", EncodeQueryValue(pin.MoreInfoUrl));
                        if (pin.PhotoUrl != String.Empty)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "_{0}", EncodeQueryValue(pin.PhotoUrl));
                        }
                    }
                }
            }

            // ja-jp is the only non en supported market for maps, so special case it
            string cultureName = CultureInfo.CurrentUICulture.Name.ToUpperInvariant();

            if (IsSupportedLanguage(cultureName))
            {
                sb.Append("&mkt=" + cultureName);
            }
            else
            {
                sb.Append("&mkt=en-us");
            }

            string queryString = sb.ToString();

            return(baseUrl + "?" + queryString);
        }
 public static string CreateLiveUrl(float latitude, float longitude, string reserved, string style, int level, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
 {
     return CreateMapUrl(LIVE_MAP_URL, latitude, longitude, reserved, style, level, pushpins, birdseyeScene);
 }
 public static string CreateLiveUrl(float latitude, float longitude, string reserved, string style, int level, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
 {
     return(CreateMapUrl(LIVE_MAP_URL, latitude, longitude, reserved, style, level, pushpins, birdseyeScene));
 }
        private void ShowCustomizeMapDialog()
        {
            using (new WaitCursor())
            {
                if (!MapForm.ValidateLiveLocalConnection(true))
                    return;

                using (MapForm mapForm = new MapForm(false, _mapOptions, ((ICommandManagerHost)_contentEditorSite).CommandManager))
                {
                    VEBirdseyeScene scene = null;
                    if (_mapSettings.MapStyle == "o")
                        scene = new VEBirdseyeScene(_mapSettings.BirdseyeSceneId, _mapSettings.BirdseyeOrientation);
                    mapForm.LoadMap(_mapSettings.Latitude, _mapSettings.Longitude, _mapSettings.Reserved, _mapSettings.MapStyle, _mapSettings.ZoomLevel, scene);
                    mapForm.Pushpins = _mapSettings.Pushpins;
                    if (mapForm.ShowDialog(this) == DialogResult.OK)
                    {
                        _mapOptions.DefaultDialogSize = mapForm.Size;
                        _mapSettings.UpdateSettings(mapForm.Latitude, mapForm.Longitude, mapForm.Reserved, mapForm.ZoomLevel, mapForm.MapStyle, mapForm.Pushpins, mapForm.BirdseyeScene);

                        SelectedContent.Files.Remove(_mapSettings.ImageFileId);
                        Size mapSize = _mapSettings.Size;
                        Debug.Assert(mapSize != Size.Empty);
                        MapContentSource.UpdateMapImage(SelectedContent, _mapSettings, mapSize);
                        _mapSettings.Size = mapSize;

                        sidebarHeaderControl1.LinkUrl = _mapSettings.LiveMapUrl;
                        sidebarHeaderControl1.RefreshLayout();

                        OnContentEdited();
                    }
                }
            }
        }
 public void JSUpdateBirdsEye(string sceneId,
     string direction,
     string sceneThumbUrl
     )
 {
     BirdseyeScene = new VEBirdseyeScene(sceneId, direction);
     OnBirdseyeChanged(EventArgs.Empty);
 }
        /// <summary>
        /// Initializes the map to a center on a set of coordinates.
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="mapStyle"></param>
        /// <param name="zoomLevel"></param>
        public void LoadMap(float latitude, float longitude, string reserved, string mapStyle, int zoomLevel, VEBirdseyeScene scene)
        {
            MapActiveObject = new MapActiveObject(new VELatLong(latitude, longitude, reserved), mapStyle, zoomLevel, scene);

            //string url = MapUrlHelper.CreateMapUrl(LocalMapUrl, latitude, longitude, mapStyle, zoomLevel);
            string url = LocalMapUrl;

            url = new Uri(url).ToString();
            explorerBrowserControl.Navigate(url);
        }
Exemple #17
0
 public void LoadMap(float latitude, float longitude, string reserved, string style, int zoomLevel, VEBirdseyeScene scene)
 {
     mapControl.LoadMap(latitude, longitude, reserved, style, zoomLevel, scene);
     UpdateMapStyle();
     UpdateMapZoomLevel();
 }
 public void UpdateSettings(float latitude, float longitude, string reserved, int zoomLevel, string style, VEPushpin[] pushpins, VEBirdseyeScene birdseyeScene)
 {
     Latitude  = latitude;
     Longitude = longitude;
     Reserved  = reserved;
     ZoomLevel = zoomLevel;
     MapStyle  = style;
     Pushpins  = pushpins;
     if (birdseyeScene != null)
     {
         BirdseyeSceneId     = birdseyeScene.SceneId;
         BirdseyeOrientation = birdseyeScene.Orientation.ToString();
     }
     else
     {
         BirdseyeSceneId     = null;
         BirdseyeOrientation = null;
     }
     MapImageInvalidated = true;
 }
 public void LoadMap(float latitude, float longitude, string reserved, string style, int zoomLevel, VEBirdseyeScene scene)
 {
     mapControl.LoadMap(latitude, longitude, reserved, style, zoomLevel, scene);
     UpdateMapStyle();
     UpdateMapZoomLevel();
 }