Sorry to post another thread.
If the windowless is set to true, In Firefox and Safari, zoom in and zoom out does not work anymore.
Can someone look into this?
Thanks.
I believe this a problem with the Silverlight plugin and how it interacts with those browsers, and I'm not sure there is currently a work around that we can use. If we don't get the event, we cant react to it. What's the reasoning behind using windowless = true in your application? I believe there are more limitations in Silverlight if you have this option set, so you should make sure there aren't other ways to achieve what you are striving for with windowless mode.
As a work around, if you can grab that event in javascript for those browser types while the mouse is over the map, you could talk over the Silverlight HTML bridge and manually change the window scale of the map by adjusting its properties.
You could also add a zoom pane, to work around the issue. I'll try to reproduce the problem here to see if there is anything else we can do, but I suspect the versions of those browsers aren't playing nice with the SL runtime in that mode.
Are you running the latest versions of both the browsers?
Here, you can try something like this to push the mouse wheel events through for those browsers:Add this javascript to the page (Make sure the changes don't conflict with other javascript you have):
function reactToScroll(delta) { slPlugin.Content.scrollHelper.SendScrollEvent(delta); } function mouseScroll(event) { var delta = 0; if (event.wheelDelta) { delta = event.wheelDelta / 120; } if (event.detail) { delta = -event.detail / 3; } if (delta != 0) { reactToScroll(delta); } } window.onload = init; var slPlugin; function init() { slPlugin = document.getElementById('mapHost'); if (slPlugin != null) { if (slPlugin.addEventListener) { slPlugin.addEventListener('DOMMouseScroll', mouseScroll, true); slPlugin.addEventListener('mousewheel', mouseScroll, true); } } }
Make sure to find the object tag for your Silverlight control on the page and addid="mapHost" to it.Then, in the code behind for your silverlight page (presumably you will have other logic in your silverlight page, so merge this in carefully):
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); HtmlPage.RegisterScriptableObject("scrollHelper", new ScrollHelper(this)); } } public class ScrollHelper { private MainPage _owner; public ScrollHelper(MainPage owner) { _owner = owner; } [ScriptableMember()] public void SendScrollEvent(double scrollChange) { double currzoom = _owner.theMap.WindowZoom; currzoom += scrollChange; if (currzoom < 0) { currzoom = 0; } _owner.theMap.WindowZoom = currzoom; } }
Please remember though that not everyone will necessarily have a mouse wheel on their computer, and that traditionally the browsers have handled the wheel very differentlly, so plugins like Silverlight have to struggle to maintain compatability and consistency accross platforms.
It seems in this case that when windowless=true on the silverlight plugin, Firefox, Chrome, and Safari do not forward mouse scroll events to the Silverlight plugin, so we have no chance to respond. I'll see if there is some work around you can perform though.
PS: Did you know you can use keyboard commands to navigate the map? You can use Page Up/Page Down to zoom, home to return to default scale, and the arrow keys to pan. These work in those browsers even if windowless=true.
I'll look into it. Do you mean you are rendering some html content in a div over a portion of the map?
There is only a little space for this map in the page, no room for a zoom pane anymore.
I am using windowless mode because a div in the page need to be right upper the map.
Please help.