0

Ich habe versucht, die Anleitung in https://github.com/apneadiving/Google-Maps-for-Rails, aber meine benutzerdefinierten Symbole immer noch nicht geladen.Benutzerdefinierte Markierung in gmaps4rails wird nicht angezeigt

@hash = Gmaps4rails.build_markers(@terminals) do |terminal, marker| 
      marker.lat terminal.latitude 
      marker.lng terminal.longitude 
     marker.picture({ 
      "url" => "/assets/marker.png", 
      "width" => 30,   
      "height" => 30 
      }) 
     end 

Das Bild marker.png ist in Assets/Bilder.

Aufbau der Karte:

<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(); 
    handler.getMap().setZoom(13); 
    handler.getMap().setOptions({styles: [{"featureType":"water","stylers":[{"saturation":43},{"lightness":-11},{"hue":"#0088ff"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"hue":"#ff0000"},{"saturation":-100},{"lightness":99}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#808080"},{"lightness":54}]},{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"color":"#ece2d9"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#ccdca1"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#767676"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#ffffff"}]},{"featureType":"poi","stylers":[{"visibility":"off"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#b8cb93"}]},{"featureType":"poi.park","stylers":[{"visibility":"on"}]},{"featureType":"poi.sports_complex","stylers":[{"visibility":"on"}]},{"featureType":"poi.medical","stylers":[{"visibility":"on"}]},{"featureType":"poi.business","stylers":[{"visibility":"simplified"}]}]}); 
}); 
</script> 

Die Karte:

<div id="map"class="col-md-8" style="height: 100vh; background-color: #E4E2E1;"> 
    </div> 

Wie es scheint: enter image description here

Wie es ohne marker.picture im Controller aussieht: enter image description here

+0

prüfen diese [SO Frage] (http://stackoverflow.com/questions/8498760/trouble-displaying-a-custom-marker-using-gmaps4rails) wenn es kann dir helfen :) – KENdi

Antwort

0

Versuchen Sie, Ihre marker.picture zu ändern:

marker.picture({ 
    url: ActionController::Base.helpers.asset_path('marker.png'), 
    width: '30',   
    height: '30' 
}) 
Verwandte Themen