如何美化OpenLayers地图
我需要构建一个 Web 应用程序来呈现具有不同标记的地图。 我想使用 OpenLayers 等解决方案,但我希望地图具有“更好”的外观(例如 http ://leaflet.cloudmade.com/)。您知道有什么库可以与 OpenLayers 一起使用来改善其外观吗?
I need to build a web app that renders a Map with different markers.
I think to use a solution as OpenLayers but i would like the maps to have a "better" look (as, for example, http://leaflet.cloudmade.com/). Do you know any library that can be used with OpenLayers to improve its look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 CSS 和图像根据需要设置地图按钮的样式。蓝色默认按钮上的一个流行主题是 https://github.com/developmentseed/openlayers_themes (更多信息http://support.mapbox.com/kb/mapping-101/openlayers-themes)
有关功能样式,请查看http://docs.openlayers.org/library/feature_styling.html
You can style the map buttons as you want using css and images. A popular theme over the blue default button is https://github.com/developmentseed/openlayers_themes (more info http://support.mapbox.com/kb/mapping-101/openlayers-themes)
For feature styling, take a look at http://docs.openlayers.org/library/feature_styling.html
如果您使用谷歌地图,您可以轻松做到这一点!
您必须做的是将 openlayers.js 脚本的源代码复制到您的公开目录,例如
public/js/openlayers.js
。脚本已缩小。您需要打开它并找到它显示google.maps.Map
的位置,并通过在必要时添加中断来缩小该语句(这只会使其更易读)。然后,您需要将 styles 属性添加到第二个参数。一些样式选项可以在这个网站上免费找到:https://snazzymaps.com/explore
最后你在您的自定义 openlayers.js 文件中应该有这样的部分:
这里的缺点是,如果 Google API 和/或 openlayers.js 脚本发生更改,您就有破坏地图的风险,因为您拥有该脚本的静态副本。我发现这是一个罕见的事件,并且为了一张更漂亮的地图而付出的代价很小。
You can do this easily if you are using google maps!
What you must do is copy the source of the openlayers.js script to your publicly available directory, such as
public/js/openlayers.js
. The script is minified. You need to open it up and find where it saysgoogle.maps.Map
and unminify this statement by adding breaks where necessary ( this just makes it more readible ). You then need to add a styles property to the second argument. Some style options can be found for free at this website:https://snazzymaps.com/explore
In the end you should have a section like this in your customized openlayers.js file:
The downside here is that if the Google API and/or the openlayers.js script ever change you risk breaking your map since you have a static copy of the script. I find that to be a rare event and is a small price to pay for a more beautiful map.
不太确定您想要“美化”哪些部分,但您可能会比查看 GeoExt 做得更糟糕,这结合了Sensha Extjs 与 openlayers 的 UI。我用它制作了一些非常有吸引力的 webGIS 应用程序
希望对
Olly有帮助
not too sure which parts you want to 'beautify' but you could do worse than having a look at GeoExt, this combines the UI of sensha Extjs with openlayers. i've used it to produce some very attractive webGIS applications
hope that is of help
Olly