Leaflet map tiles don't load on a Meteor Cordova app

idoivri

I'm building a meteor / cordova app that consists of a template with a Leaflet map, where the tiles and icons are provided by mapbox (I'm not sure if it's relevant).

The app is using the bevanhunt:leaflet package, and is running fine when deployed on a web browser.

var map; //outside of the template

Template.map.rendered = function() {
    L.Icon.Default.imagePath = 'images';

    if (!map) {
        map = L.map('map', {
            doubleClickZoom: false,
            zoomControl: false
        });
    }

    var attributionText = "<a href='http://zencity.io/' target='_blank'>ZenCity &copy; </a>" +
    "<a href='https://www.mapbox.com/about/maps/' target='_blank'> Mapbox &copy;" +
    " OpenStreetMap</a>";

     L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
        maxZoom: 18,
        attribution: attributionText,
        id: 'someID'
    }).addTo(map);
  //some code to put makers on the map
}

I should say that the markers / popups appear fine (But their images are not present; a minor problem, I will try to take care of that), but the map does not seem to initialize.

Do I need to create the map outside of the Template.map.rendered code? Do I need to add configuration to enable leaflet / mapbox to work with Cordova/android?

Any help would be appreciated here.

Stephan

Meteor 1.0.4 introduced the App.accessRule setting to mobile-config.js. You need to add the URL for the tile provider to it like this:

App.accessRule('https://*.tiles.mapbox.com/*');

Basically, for security reasons Cordova apps may not connect to any URL they like. This is what this white list is used for. It restricts from what URLs content may be loaded. As the tile URL is different from your app URL it gets rejected by default. Using the App.accessRule setting you allow additional URLs. The supported domain patterns vary slightly between Android and iOS, you can find them in the official docs. Asterisks (*) can (and must) be used as wild cards, here for supporting the dynamic subdomain.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Angular Leaflet in Cordova wrapper doesn't load tiles due to protocol mismatch

From Dev

Leaflet map not loading tiles

From Java

Leaflet popup graphs don't correspond to map

From Dev

leaflet map is loading partial tiles

From Dev

Switching to Leaflet Map Doesn't Load

From Dev

Leaflet show map on hover - map doesn't load correct

From Dev

Map tiles not loading until a zoom is executed(Leaflet)

From Dev

Leaflet js map only showing a few tiles

From Dev

Cordova Windows Phone 8.1 app lifecycle events don't fire?

From Dev

Google maps api fails to load map tiles

From Dev

How leaflet js load tiles from file system

From Dev

How to add square tiles to leaflet map with hovering effect?

From Dev

How to remove circle overlay from leaflet/mapbox map tiles?

From Dev

Leaflet map tiles not visible in reveal.js presentation within R?

From Dev

Meteor cordova on Android building app

From Dev

My google Map don't load all locations

From Dev

Cordova ios app can't load device data

From Dev

Cordova ios app can't load device data

From Dev

Ionic / Leaflet - Can't get Tiles 404 Not Found (from cache)

From Dev

Ionic / Leaflet - Can't get Tiles 404 Not Found (from cache)

From Dev

Chunks don't load

From Dev

Creating a button for Leaflet JS "panTo spot on map" outside of the map in Meteor

From Dev

Creating a button for Leaflet JS "panTo spot on map" outside of the map in Meteor

From Dev

Cordova Load Remote Site into App

From Dev

Using jpeg tiles in leaflet

From Dev

NASA tiles with leaflet in R

From Dev

Leaflet - Event on tiles loading

From Dev

Leaflet broken tiles with ionic

From Dev

Leaflet drawing tiles disjointly

Related Related

HotTag

Archive