按下后退按钮时地图缩放问题
我遇到了这个奇怪的问题,这让我非常沮丧。我在视图上有一个地图控件。使用主页上的按钮调用地图视图页面。我已将地图缩放属性绑定到视图模型中的缩放属性。当我第一次打开页面时,双击页面,地图放大到下一个级别,例如从缩放级别13到13.122234到14(调用set属性两次),没有问题(即使我不真正理解为什么它必须分两步完成)。但是,如果我按后退按钮,返回主页,然后单击返回地图页面,当我双击地图时,缩放全部混乱。它放大,然后似乎稍微缩小,然后再放大一点,使变焦看起来非常不稳定,而且它没有完全放大,例如从 13 到 14 再到 13.8。
我不知道发生了什么事。第一次和第二次导航到地图页面之间调用的代码似乎没有区别,但行为不同。显然,调用的代码肯定存在一些差异,但我看不到它。每次我按下后退按钮然后再次返回页面后尝试放大时,它似乎也会调用“缩放设置”属性 5 或 6 次!?有谁知道地图缩放属性如何运作的详细信息以及关于我按下后退按钮后为什么会出现故障的任何想法吗?干杯。
I've got this weird problem thats been really frustrating me. I've got a map control on a view. The map view page is called using a button from the main page. Ive bound the Maps Zoom property to a zoom property in my view model. When i open the page for the first time, double click on the page, the map zooms in to the next level, e.g. from zoom level 13 to 13.122234 to 14 (calls the set property twice), no problems there (even though i dont really understand why it has to do it in 2 steps). However, if I press the back button, bringing me back to the main page, then click back into the map page, when i double click the map the zoom is all messed up. It zooms in, then seems to zoom back out slighty, then zooms back in a bit, making the zoom look really jerky, plus it doesnt zoom in fully, e.g. goes from 13 to 14 to 13.8.
I dont know whats going on. There seems to be no difference in what code is called between the first and second navigations to the map page, yet the behaviour is different. Obviously there must be some difference in what code is being called but i cant see it. It also seems to call the Zoom Set property 5 or 6 times each time i try to zoom in after Ive pressed back button then gone back to the page again!!? does anyone have any detailed info on how the map zoom property functions and any idea on why its malfunctioning after i press the back button? Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前也遇到过同样的变焦问题。就我而言,问题在于由于页面导航而无意中将缩放属性绑定到两个不同的地图。确保每次导航到页面时都不会创建新地图,然后将
ZoomLevel
绑定到同一属性。保证这种情况不会发生的一种方法是,当您离开带有地图的页面时取消绑定
Zoomlevel
属性,然后在您导航回该页面时重新绑定它。虽然这不是很好的编码实践......I've experienced the same zoom problems before. In my case, the issue was with the zoom property being bound to two different maps inadvertently because of page navigation. Make sure you aren't creating a new map each time you navigate to the page and then binding the
ZoomLevel
to the same property.A way to guarantee that it doesn't happen is to unbind the the
Zoomlevel
property when you leave the page with the map and then rebind it when you navigate back to it. Though this isn't very good coding practice...