Ich konnte den Marker-Cluster in diesem Format innerhalb der index.html.erb-Datei hinzufügen. Als ich beschloss, Infofenster hinzuzufügen, begann meine Karte zu brechen.Wie füge ich Clustermarker zu Gmaps4rails hinzu?
<script type = "text/javascript">
handler = Gmaps.build('Google',
{markers:
{clusterer: {
gridSize: 60,
maxZoom: 20,
styles: [ {
textSize: 10,
textColor: '#ff0000',
url: 'assets/creative/m1.png',
height: 60,
width: 60 }
, {
textSize: 14,
textColor: '#ffff00',
url:'assets/creative/m2.png',
height: 60,
width: 60 }
, {
textSize: 18,
textColor: '#0000ff',
url: 'assets/creative/m3.png',
width: 60,
height: 60}
]}}}
);
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
Als ich meine Infofenster zu Web-App unter meiner custom.js.coffee Datei als
class InfoBoxBuilder extends Gmaps.Google.Builders.Marker
create_infowindow: ->
return null unless _.isString @args.infowindow
boxText = document.createElement("div")
boxText.setAttribute('class', 'panel panel-green')
boxText.innerHTML = @args.infowindow
@infowindow = new InfoBox(@infobox(boxText))
infobox: (boxText)->
content: boxText
pixelOffset: new google.maps.Size(-140, 0)
boxStyle:
width: "280px"
@buildMap = (markers)->
handler = Gmaps.build 'Google', { builders: { Marker: InfoBoxBuilder}
}
handler = Gmaps.build 'Google', { builders: { markers:
{clusterer: {
gridSize: 60,
maxZoom: 20,
styles: [ {
textSize: 10,
textColor: '#ff0000',
url: 'assets/creative/m1.png',
height: 60,
width: 60 }
, {
textSize: 14,
textColor: '#ffff00',
url:'assets/creative/m2.png',
height: 60,
width: 60 }
, {
textSize: 18,
textColor: '#0000ff',
url: 'assets/creative/m3.png',
width: 60,
height: 60}
]}}} } #dependency injection
handler.buildMap { provider: {}, internal: {id: 'map'} }, ->
markers = handler.addMarkers(markers)
handler.bounds.extendWith(markers)
handler.fitMapToBounds()
hinzufügen erhalte ich den Marker-Cluster arbeiten, aber ich das Infofenster Formatierung verlieren. Wie injiziere ich das infowwindow und den Markierungsclustercode in die custom.coffee.js Akte.
Bitte lesen [Unter welchen Umständen kann ich "dringende" oder andere ähnliche Sätze zu meiner Frage hinzufügen, um schnellere Antworten zu erhalten?] (// meta.stackoverflow.com/q/326569) - das ist die Zusammenfassung ist kein idealer Weg, um Freiwillige anzusprechen, und ist wahrscheinlich kontraproduktiv, um Antworten zu erhalten. Bitte unterlassen Sie das Hinzufügen zu Ihren Fragen. – halfer