美国在Rails中的高地图 [英] Highmaps with US States in Rails

查看:114
本文介绍了美国在Rails中的高地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的rails应用程序中添加一个小部件,在其中我将按照给定的演示在高图中

I am trying to add a widget in my rails application, in which i am going to display the US states maps as given Demo here in highcharts

该应用程序正在使用版本4.0.4highcharts-rails gem,以在应用程序中显示其他一些图表.要使用这些地图,我尝试将来自gem的js文件包含在application.js文件中,如下所示.

The app is using highcharts-rails gem of version 4.0.4, to display some other charts in the application. To use the maps, i am trying to include the js files from gem in application.js file as follows.

//= require highcharts
//= require highcharts/modules/data
//= require highcharts/modules/map

以及用于在application.html.erb

<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>

我能够获取状态码Highcharts.maps['countries/us/us-all'],并根据需要从应用程序构造data.但是地图没有显示任何东西,也没有在console中看到任何错误.

I am able to get the state codes Highcharts.maps['countries/us/us-all'] and also constructed the data from application as required. But the map is not displaying any thing and not seeing any errors in the console also.

但是当我从application.js文件中删除包含行并显式添加Java Script文件时,该映射将完美加载而没有任何问题.以下是我在布局中添加的两个js文件.

But when i remove the including lines from application.js file and add the Java Script files explicitly, the map is loading perfectly without any issues. The below are the two js files that i am adding in my layout.

<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>

有什么帮助,为什么当我通过gem包含文件时为什么不加载地图?

Any help, why it is not loading the maps when i include the files through gem ?

预先感谢.

推荐答案

最终能够使其与gem本身一起使用,但是我必须明确地包含

Finally able to make it work with the gem itself, but i have to explicitly include the

//= require highcharts/modules/map

,其中包含 http://www.highcharts.com/download 中的文件以获取高地图插件,在Highmaps-1.0.4/js/modules/map.src.js

with the file that is available in http://www.highcharts.com/download for highmaps plugin, available in Highmaps-1.0.4/js/modules/map.src.js

github

这篇关于美国在Rails中的高地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆