Ionic displays these broken tiles when loading a map.
I've tried both loading bower and straight from Leaflet but nothing has changed. I'm using a special Leaflet Directive but event with pure leaflet code, I still get these broken tiles.
including the libraries in index.html
<!-- Extra libraries -->
<script src="js/lib/leaflet/leaflet.css"></script>
<script src="js/lib/leaflet/leaflet.js"></script>
<script src="js/lib/leaflet/angular-leaflet-directive.min.js"></script>
map.html
<ion-view view-title="Map">
<ion-content scroll="false">
<leaflet id="map" center="map.center" defaults="map.defaults"></leaflet>
</ion-content>
</ion-view>
controllers.js
var app = angular.module('controllers', ['leaflet-directive']);
app.controller('MapController', function($scope) {
$scope.map = {
defaults: {
tileLayer: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
maxZoom: 18,
zoomControlPosition: 'bottomleft'
},
center: {
lat: 51.505,
lng: -0.09,
zoom: 4
}
};
});
are you sure this is correct?
center: {
lat: 51.505,
lng: -0.09,
zoom: 4
}
i have a complete working example here: DC Web Women Code(Her) Ionic Framework Sample App
<!-- Extra libraries -->
<script src="js/lib/leaflet/leaflet.css"></script>
<script src="js/lib/leaflet/leaflet.js"></script>
<script src="js/lib/leaflet/angular-leaflet-directive.min.js"></script>
The first line. The CSS file was accidentally linked as a script instead of a stylesheet. Without leaflet.css, there was a problem drawing the map.
The new code should be:
<!-- Extra libraries -->
<link href="js/lib/leaflet/leaflet.css" rel="stylesheet">
<script src="js/lib/leaflet/leaflet.js"></script>
<script src="js/lib/leaflet/angular-leaflet-directive.min.js"></script>