Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在ruby中显示自定义google地图图标png?_Ruby On Rails_Ruby_Google Maps - Fatal编程技术网

Ruby on rails 如何在ruby中显示自定义google地图图标png?

Ruby on rails 如何在ruby中显示自定义google地图图标png?,ruby-on-rails,ruby,google-maps,Ruby On Rails,Ruby,Google Maps,我设计了一个自定义png图标,用于谷歌地图,在ruby中通常是这样的- <%= image_tag 'icon.svg', class: "imgstar" %> 这是我的脚本显示位置的样子,但我真的不确定在哪里以及如何显示我设计的图标 <% content_for :custom_script do %> <script type="text/javascript"> var mapStyles = [{"feature

我设计了一个自定义png图标,用于谷歌地图,在ruby中通常是这样的-

<%= image_tag 'icon.svg', class: "imgstar" %>

这是我的脚本显示位置的样子,但我真的不确定在哪里以及如何显示我设计的图标

<% content_for :custom_script do %>
        <script type="text/javascript">
        var mapStyles = [{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}]
        handler = Gmaps.build('Google');
        handler.buildMap({
        provider: {
        zoom: 15,
        center: new google.maps.LatLng(<%= @property.address.latitude %>, <%= @property.address.longitude %>),
        styles: mapStyles
        },
        internal: {id: 'map'}
        }, function () {
        handler.addMarkers(<%=raw @location.to_json %>);
        });
        </script>
        <% end %>

var mapStyles=[{“特征类型”:“景观”、“样式”:[{“色调”:“#FFBB00”}、{“饱和度”:43.4000000000000006}、{“亮度”:37.59999999994}、{“伽马”:1}、{“特征类型”:“道路.公路”、“样式”:[{“色调”:“#FFC200”}、{“饱和度”:-61.8}、{“亮度”:45.599999999994}、{“伽马”:1}、{“道路特征类型”:{{“饱和度”:#00FF6A“},{“饱和度”:-1.0989010989011234},{“亮度”:11.2000000000000017},{“伽马”:1}]}]
handler=Gmaps.build('Google');
handler.buildMap({
提供者:{
缩放:15,
中心:新google.maps.LatLng(,),
样式:贴图样式
},
内部:{id:'map'}
},函数(){
addMarkers();
});

我猜你正在使用gem
gmaps4rails
。看看下面的例子,我想试一试:

handler.addMarkers(<%=raw @location.to_json %>, picture: {
        url: "<%= image_url 'icon.svg' %>",
        width:  36,
        height: 36
      });
handler.addMarkers(,图片:{
url:“”,
宽度:36,
身高:36
});