六角形平移控制

发布于 2024-10-14 12:05:59 字数 437 浏览 6 评论 0原文

我需要在画布上渲染大量的六角形。我想做到这一点,以便仅渲染用户可见的图块,并在用户滚动时加载其他六角形图块(使用拖动或箭头键或平移控件)。我脑子里已经有了基本的想法,但我正在寻求帮助,以提出一个更强大、可扩展的解决方案。

我现在的想法和可以做的是

:识别需要加载到屏幕的图块并从服务器获取用于渲染它们的数据 b.当用户拖动时,找出需要加载的新图块集并获取数据并再次重新加载整个屏幕。

这可行,但它不会给人滚动的感觉 - 它本质上是突然重新定位所有内容。理想情况下,我希望在滚动时获得谷歌地图的感觉。我一直在尝试在地图一侧加载一些图块,并且仅在拖动时滚动底层画布,但这效果不太好,因为画布用完了......如果我有一个画布,那就太棒了行为就像一个循环缓冲区,因此在任何方向上滚动只会在内存中保留一定数量的图块,并且我可以在所有方向上连续滚动。

非常感谢任何想法或有用的提示。

谢谢!

I need to render a large number of hextiles on a canvas. I would like to make this such that I render only the tiles that are visible to the user and load additional hextiles as the user scrolls (using drag or arrow keys or a pan control). I've the basic idea in my head but I'm looking for help in coming up with a more robust solution that will scale well.

What I have in mind and can do right now:

a. identify the tiles that need to be loaded to the screen and get the data for rendering them from the server
b. when the user drags, figure out the new set of tiles that need to be loaded and get the data and reload the whole screen again.

This works but it doesn't give the feeling of scrolling - it essentially suddenly repositions everything. Ideally, I would like to get the feeling of google maps when scrolling this. I've been playing with loading some tiles on the side off the map and only scrolling the underlying canvas when dragging but this doesn't work too well because the canvas runs out... it would be really neat if I had a canvas that behaved like a circular buffer so scrolling in any direction only kept a certain number of tiles in memory and I can continuously scroll in all directions.

Any thoughts or helpful hints are much appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳根太软 2024-10-21 12:05:59

我建议使用 Google Maps Flash API 作为起点。您可以创建一个 CustomTileLayer,如果您有一个大的源图像,您可以搜索图像金字塔制作器,将您的图像分割成不同缩放级别的样本(通常我相信它最终会创建一个使用缩放级别的文件夹结构)作为文件夹名称,然后每个文件夹中都有 x,y 平铺,具体取决于图像的分辨率和缩放级别)。如果以任何方式都不需要缩放,那么您只需要一个缩放级别,并且希望禁用地图控件中的任何缩放控件。让我知道您是否有理由避免这样做或认为它不是一个好的解决方案(可能只是不知道它的存在,但我想如果您想要类似谷歌地图的行为方式,为什么不使用谷歌地图作为的基础)。如果您在深入了解后需要更多帮助,请告诉我,我很乐意提供帮助,我自己从未实现过 CustomTileLayer,但对 Google Maps Flash API 有一些经验(它也是灵活的,请确保你使用正确的swc,一个是Flash,另一个是Flex,不包括两者)。

祝你好运,
肖恩

http://nl-samples.googlecode。 com/svn/trunk/flexmap/9a/bin-release/CustomProjection.html

I would suggest using the Google Maps Flash API as the starting point for this. You can create a CustomTileLayer and if you have a single large source image you can search around for image pyramid makers that will slice up your image into samples for different zoom levels (usually I believe it ends up creating a folder structure that uses the zoom level as the folder name and then has x,y tiles in each folder depending on the res of the image and zoom level). If zooming isn't a requirement in any way you'd just have a single zoom level and would want to disable any zoom controls in the Map control. Let me know if there's a reason you're avoiding this or believe it to not be a good solution (possibly just weren't aware of it's existence but I figure if you want something like how google maps behaves, why not use google maps as the basis). If you need more help with this after digging in let me know and I'll be happy to help, I haven't ever implemented a CustomTileLayer myself but have a bit of experience with the Google Maps Flash API (it's flex as well make sure you use the right swc one is Flash only the other is Flex don't include both).

Good luck,
Shaun

http://nl-samples.googlecode.com/svn/trunk/flexmap/9a/bin-release/CustomProjection.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文