2

The removeMarkers will get rid of one marker, the last one added. The problem is in addMarker. addMarker will be called for each "place" and should add one marker to the map and one marker to the markers array. Look at where this line markers[i] = marker; is and you should see that the markers array is incorrect.


1

The removeMarkers function is really is no more than a line of code as below,simply passing a null to the setMapOnAll() function would suffice : setMapOnAll(null);


Only top voted, non community-wiki answers of a minimum length are eligible