apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.27k stars 382 forks source link

for loop in polylines #466

Closed samarthsikotara closed 9 years ago

samarthsikotara commented 9 years ago

I have a below function which displays a map. but how to set the loop in .addPolylines() function. I get proper latitude & longitude but I added a loop but it has displayed a blank map. can you help me to fix it?

create_map(<%= raw @boundary_points.to_json %>);

function create_map(boundary_points){ var handler = Gmaps.build('Google');

handler.buildMap({ internal: {id: 'geolocation'}}, function(){

for (i = 1; i < boundary_points.length; i++) { 
    var ls = boundary_points[i].trim().split(" ");
}

var polylines = handler.addPolylines(
    [
     [
       for (i = 1; i < boundary_points.length; i++) { 
    var ls = boundary_points[i].trim().split(" ");
       {lat:  ls[0], lng: ls[1]},           
       }

     ]
    ],
    { strokeColor: '#FF0000'}
);
handler.bounds.extendWith(polylines);
handler.fitMapToBounds();
handler.getMap().setZoom(15);
alert(boundary_points);

}); }

apneadiving commented 9 years ago

please ask questions on stackoverflow