Does not show markers


#1

My project does not show markers on the map.
This is my code:
Controller:
app.controller('MainController', ['$scope', 'places', function($scope, places) {
$scope.mapCenter = {
lat: 40.741934,
lng: -74.004897,
zoom: 17
};
places.success(function(data) {
$scope.geodata = data;
$scope.mapMarkers = geodataToMarkers($scope.geodata);
});
}]);

index:










<div class="header">
  <div class="container-fluid">
    <h1 class="pull-left">NearMe</h1>
  </div>
</div>

<div class="main" ng-controller="MainController">
  <div class="container-fluid" id="map-canvas">
    <leaflet center="mapCenter" markers="mapMarkers"></leaflet> 
  </div>
</div>

<!-- Modules -->
<script src='js/app.js'></script>

<!-- Controllers -->
<script src="js/controllers/MainController.js"></script>

<!-- Directives -->
<script src="js/vendor/helpers.js"></script>

<!-- Services -->
<script src='js/services/places.js'></script>


places.js:
app.factory('places', ['$http', function($http) {
return $http.jsonp('https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=5000&gscoord=40.741934%7C-74.004897&gslimit=30&format=json&callback=JSON_CALLBACK')
.success(function(data) {
return data;
})
.error(function(data) {
return data;
});
}]);

helper.js:
var geodataToMarkers = function(geodata) {
var places = geodata.query.geosearch;
var markers = [];
for(var i=0; i place = {
lat: places[i].lat,
lng: places[i].lon,
message: getMessage(places[i].title)
}
markers.push(place);
}

return markers;
}

var getMessage = function(title) {
var url = "http://en.wikipedia.org/wiki/" + title;
return "" + title + "";
}


#2

Your code works for Step 1 and 2. The error is in Step 3. Seems like your for-loop is not formatted properly.

Incorrect:

for(var i=0; i place = {
lat: places[i].lat,
lng: places[i].lon,
message: getMessage(places[i].title)
}

Correct:

for(var i=0; i<places.length; i++) {
    place = {
      lat: places[i].lat,
      lng: places[i].lon,
      message: getMessage(places[i].title)
    }
    markers.push(place);
  }

The Chrome console gave me this error: Uncaught SyntaxError: Unexpected identifier helpers.js:4, so I knew to look in helpers.js for an error.