I have a problem with bounds when there is only one element to display on the map it gives me an error:
Uncaught Error: Invalid LatLng object: (NaN, NaN) at L.LatLng (LatLng.js:24) at Object.unproject (Projection.SphericalMercator.js:29) at Object.pointToLatLng (CRS.js:31) at NewClass.unproject (Map.js:899) at NewClass._getBoundsCenterZoom (Map.js:250) at NewClass.fitBounds (Map.js:269) at Class.didCreateLayer (leaflet-map.js:59) at Class.didInsertParent (base-layer.js:90) at Object.applyStr [as default] (ember.debug.js:38924) at tryInvoke (ember.debug.js:39441)
Also the same happens when there are two markers with the same location. When there are two different locations added to the bounds everything is correct.
In the controller based on the results that I get, I create the bounds like this:
var latLngs = Ember.A();
this.get('results').forEach(function(value){
latLngs.push(value.get('location'));
});
this.set('bounds', L.latLngBounds(latLngs));
Then in the template I have something like this:
<h4></h4> <dl> <dt></dt> <dd> , </dd> <dt></dt> <dd class="rating">}</dd> </dl>
Each element of the results has property location which is created in following way in the model:
location: (function() { return L.latLng(parseFloat(this.get('latitude')), parseFloat(this.get('longitude'))); }).property('latitude', 'longitude'),
What can be the problem? Should I create the bounds in a different way?
Thank you for your help!
Aucun commentaire:
Enregistrer un commentaire