dictionary - Mapbox fitBounds, function bounds map but does not render tiles -
Here, my javascript code to map the fit ballers of that map and then into that map.
The map meets the boundaries according to the geography, but the problem is that when a marker is on the map and I try to be bound, the map tiles images are not render.
This marker only displays no tile images in the map.
var latLongCollection = []; Var map; $ (Document) .ready (function () {map ();}); Function map () {map = L.mapbox.map ('DivId', 'ProjectId'); get data(); } Function: AjaxSuccess, error: function () {$ .jax ({type: "GET", url: someUrl, data type: "json", contentType: "application / json; charset = utf-8" {} }); } Function AjaxSuccess (data) {if (data == empty; data.length == 0) {return; } Var geoJson = {"type": "feature collection", "features": []}; $ .each (data, function (index, value) {var latitude = parseflow (value.latidued), longitude = parseflot (value lonetuct); if (latitude & latitude) {var dataJson = {type: "feature" , Geometry: {type: "point", coordinates: [longitude, latitude]}, properties: {someProp: value.SomeProperty,}}; geoJson.features.push (vehicle Jason);}}); Var markerlayer = l.mapbox. Featurelere (Geojosan) .addTo (map); MarkerLayer.Eachleire (function (marker) {var feature = marker.feature; var featureproperty = feature properties; if (featureproperty.SopProp) {marker.set icon (LDIIIcon ({html: 'htmlstring', icon size: [35, 75 ]});} Other {marker.setikon (LDIIIcon ({html: 'otherhammstling', icon size: [35, 75]}))}} latLongCollection.push (marker._latlng);}); Markerlayer.one ('click', function (e) {map.panTo (e.layer.getLatLng ());}); If (latLongCollection.length & gt; 0) {map.fitBounds (latLongCollection); }}
If anyone is still struggling with it, then this one Bug Magazine:
It has been fixed in the latest version, but if you can not update, you can work around the running position by setting the timeout:
< Code> setTimeout (function () {Map.fitBounds (latLongCollection);}, 0);
Comments
Post a Comment