Here is my javascript code for rendering markers on the map and after that fitBounds of that map.
The graphs of the maps are suitable for matching the geoison, but the problem is that when there is any marker on the map, and I try to match the attached ones, the images on the tile map do not get rendered.
Only markers are displayed on the map, no image fragments.
var latLongCollection = []; var map; $(document).ready(function() { map(); }); function map() { map = L.mapbox.map('DivId', 'ProjectId'); GetData(); } function GetData() { $.ajax({ type: "GET", url: someUrl, dataType: "json", contentType: "application/json; charset=utf-8", success: AjaxSuccess, error: function () { } }); } function AjaxSuccess(data) { if (data == null || data.length == 0) { return; } var geoJson = { "type": "FeatureCollection", "features": [] }; $.each(data, function (index, value) { var latitude = parseFloat(value.Latitude), longitude = parseFloat(value.Longitude); if (latitude && longitude) { var dataJson = { type: "Feature", geometry: { type: "Point", coordinates: [longitude, latitude] }, properties: { someProp: value.SomeProperty, } }; geoJson.features.push(vehicleJson); } }); var markerLayer = L.mapbox.featureLayer(geoJson).addTo(map); markerLayer.eachLayer(function (marker) { var feature = marker.feature; var featureProperty = feature.properties; if (featureProperty.someProp) { marker.setIcon(L.divIcon({ html: 'htmlstring', iconSize: [35, 75] })); } else { marker.setIcon(L.divIcon({ html: 'anotherhtmlstring', iconSize: [35, 75] })); } latLongCollection.push(marker._latlng); }); markerLayer.on('click', function (e) { map.panTo(e.layer.getLatLng()); }); if (latLongCollection.length > 0) { map.fitBounds(latLongCollection); } }
dictionary leaflet mapbox
111
source share