2014-09-26 4 views
0

У меня есть этот код..конструкции отлично.gmaps4rails marker не кликабельны после добавления пользовательских изображений

Контроллер:

@locations = Location.where(:country_id => @country.id) 


    @hash = Gmaps4rails.build_markers(@locations) do |location, marker| 
     marker.lat location.latitude 
     marker.lng location.longitude 
     marker.infowindow location.description 
    end 

Вид:

<script type=text/javascript> 

    handler = Gmaps.build('Google'); 
    handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ 
     markers = handler.addMarkers(<%=raw @hash.to_json %>); 
     handler.bounds.extendWith(markers); 
     handler.fitMapToBounds(); 


    }); 
</script> 

Теперь я хочу, чтобы добавить пользовательские маркеры (категория) показывают, каждое место принадлежит к категории.

@hash = Gmaps4rails.build_markers(@locations) do |location, marker| 
     marker.lat location.latitude 
     marker.lng location.longitude 
     marker.picture({ 
     "url" => "/assets/" + location.category + ".png", 
     "width" => "30",   
     "height" => "30" 
     }) 
     marker.infowindow location.description 
    end 

HTML

handler = Gmaps.build('Google'); 
       handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ 
        markers = handler.addMarkers([{"lat":43.3851,"lng":12.3856,"picture":{"url":"/assets/apartment.png","width":"25","height":"25"},"title":"Apartment Magazzino of Villa Il Frantoio is located in Umbria at the edge of a small \"borgo\" (a group of houses standing together). The house lies in a peaceful setting, but is centrally located at the same time? it is only a 10 minute drive to the shops and restaurants. \r\n \r\n","infowindow":"Apartment Magazzino of Villa Il Frantoio is located in Umbria at the edge of a small \"borgo\" (a group of houses standing together). The house lies in a peaceful setting, but is centrally located at the same time? it is only a 10 minute drive to the shops and restaurants. \r\n \r\n"},{"lat":43.3851,"lng":12.3856,"picture":{"url":"/assets/apartment.png","width":"25","height":"25"},"title":"Apartment Magazzino of Villa Il Frantoio is located in Umbria at the edge of a small \"borgo\" (a group of houses standing together). The house lies in a peaceful setting, but is centrally located at the same time? it is only a 10 minute drive to the shops and restaurants","infowindow":"Apartment Magazzino of Villa Il Frantoio is located in Umbria at the edge of a small \"borgo\" (a group of houses standing together). The house lies in a peaceful setting, but is centrally located at the same time? it is only a 10 minute drive to the shops and restaurants"}); 
       handler.bounds.extendWith(markers); 
       handler.fitMapToBounds(); 


      }); 

это работает в случае маркеров (разных баз на категории), но маркеры не кликабельны больше. Что я делаю не так?

thanks..remco

+0

Что полученный HTML? – apneadiving

+0

обновленный вопрос с html – Remco

ответ

2

Заменить:

"width" => "30",   
    "height" => "30" 

С:

"width" => 30,   
    "height" => 30 

Они должны быть номера

+0

спасибо! работает!! – Remco

Смежные вопросы