0

文档说使用谷歌地图时不需要提供者密钥。但是,我使用我的 Google API 密钥来跟踪我的使用情况。

从 gem 中的 _scripts.html.erb 文件来看,似乎没有内置支持将 provider_key 与 Google 地图一起使用。是对的吗?

    <% if enable_js == true && scripts.try(:to_sym) != :none %>
      <% case map_options.try(:[], :provider) %>
      <% when "openlayers" %>
        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
      <% when "mapquest" %>
        <script src="http://mapquestapi.com/sdk/js/v6.0.0/mqa.toolkit.js?key=<%= map_options.try(:[], :provider_key) %>"></script>
      <% when "bing" %>
        <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <% else %>
        <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry<%= gmaps4rails_js_libraries(map_options.try(:[], :libraries)) %>"></script>
        <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
        <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
        <script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>  
      <% end %>

      <% if Rails::VERSION::MAJOR >= 3 && Rails::VERSION::MINOR < 1 %>
        <% unless scripts.try(:to_sym) == :api %>
          <%= javascript_include_tag 'gmaps4rails/gmaps4rails.base.js' %>
        <% end %>
        <% case map_options.try(:[], :provider) %>
        <% when "openlayers" %>
          <%= javascript_include_tag 'gmaps4rails/gmaps4rails.openlayers.js' %>
        <% when "mapquest" %>
          <%= javascript_include_tag 'gmaps4rails/gmaps4rails.mapquest.js' %>
        <% when "bing" %>
          <%= javascript_include_tag 'gmaps4rails/gmaps4rails.bing.js' %>
        <% else %>
          <%= javascript_include_tag 'gmaps4rails/gmaps4rails.googlemaps.js' %>
        <% end %>
      <% end %>
    <% end  %>

如果是,是否有计划添加对 Google 地图提供商密钥的支持?还是我最好自己破解它?:-P

4

1 回答 1

1
    <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry<%= gmaps4rails_js_libraries(map_options.try(:[], :libraries)) %>"></script>
    <script type="text/javascript" src="https://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
    <script type="text/javascript" src="https://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
    <script type="text/javascript" src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>  

需要修改src。

于 2012-04-11T13:46:29.767 回答