JVector 交互式地图未在 Rails 3 中渲染
我一直在尝试在我的 Rails 3 应用程序中使用这个非常酷的 JVector Interactive 地图插件,但我一定做错了什么,因为地图没有渲染。我还没有太多地使用 JQuery 和 Rails,所以在这方面我还是个新手。我创建了一个名为 Maps 的控制器和一个名为 Intro.html.erb 的视图,其中包括本教程中的 html: http://developer.practicalecommerce.com/articles/2988-Create-an-Interactive-Map-with-jVectorMap
我也拆分将我的 .js 函数放入 application.js 中。由于这不起作用,我发现了一些其他代码,我尝试将其放入 Intro.html.erb 文件中:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="public/javascripts/jquery.vector-map.css" type="text/css" media="screen" />
<script src="public/javascripts/jquery.min.js"></script>
<script src="public/javascripts/jquery.vector-map.js"></script>
<script src="public/javascripts/world-en.js"></script>
<script>
$(function(){
$('#map').vectorMap();
});
</script>
</head>
<body>
<div id="map" style="width: 600px; height: 400px;"></div>
</body>
</html>
它仍然没有渲染。我正在尝试在我的开发环境中运行它并指向本地文件。例如:public/javascripts/world-en.js"
任何帮助将不胜感激。
I've been trying to use this really cool JVector Interactive map plugin with my Rails 3 app but I must be doing something wrong because the map is not rendering. I haven't used JQuery much with Rails so am kind of new at this. I created a controller called Maps and a view called Intro.html.erb, which included my html from this tutorial: http://developer.practicalecommerce.com/articles/2988-Create-an-Interactive-Map-with-jVectorMap
I also split up my .js functions by putting them in application.js. Since that didn't work I found some other code that I tried to put in my Intro.html.erb file:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="public/javascripts/jquery.vector-map.css" type="text/css" media="screen" />
<script src="public/javascripts/jquery.min.js"></script>
<script src="public/javascripts/jquery.vector-map.js"></script>
<script src="public/javascripts/world-en.js"></script>
<script>
$(function(){
$('#map').vectorMap();
});
</script>
</head>
<body>
<div id="map" style="width: 600px; height: 400px;"></div>
</body>
</html>
It's still not rendering. I'm trying to run this in my development environment and am pointing locally to the files. For example: public/javascripts/world-en.js"
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想使用“世界地图”,但在您的功能中您正在定义“#map”。这是您可以尝试的正确代码:
这是包含您需要的文档的文件夹。下载以下文件夹并将其解压到本地主机上的 htdocs
You want to use "world map" but in your finction you are defining the"#map". Here is the correct code you may try:
Here is the folder with docs you need. Download and unzip the following folder to you htdocs on your local host
同样的问题,通过在 js 初始化中指定导入的地图来解决
Same problem, fixed by specifing the imported map into the js initialization