Leaflet / Leaflet

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦
https://leafletjs.com
BSD 2-Clause "Simplified" License
41.33k stars 5.83k forks source link

Leaflet Requirejs L undefined #3260

Closed tommykennedy closed 9 years ago

tommykennedy commented 9 years ago

I am getting an L undefined error when trying to use the command L.GeoIP.centerMapOnPosition(map, 15);

I have export the variable L but it doesnt seem to make a difference.

Main.js

/*global require */

'use strict';

window.name = 'NG_DEFER_BOOTSTRAP!';

require.config({
    'baseUrl': '/js',
    'paths': {
        'angular': '//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular',
        'jquery': '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min',
        'bootstrap': '//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min',
        'socket.io': 'https://cdn.socket.io/socket.io-1.3.3',
        'sails.io': 'dependencies/sails.io',
        'ngSails': 'angular-sails/dist/angular-sails',
        'ui.bootstrap': 'https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap.min',
        'angularFileUpload': 'angular-file-upload/angular-file-upload.min',
        'leaflet-directive': 'angular-leaflet-directive/dist/angular-leaflet-directive.min',
        'leaflet': 'leaflet/dist/leaflet-src'
    },
    'shim': {
        'angular': {
            'exports': 'angular'
        },
        'ngSails': {
            'deps': ['angular', 'socket.io', 'sails.io']
        },
        'ui.bootstrap': {
            'deps': ['angular'],
        },
        'bootstrap': {
            'deps': ['jquery']
        },
        'socket.io': {
            'exports': 'io'
        },
        'sails.io': {
            'deps': ['socket.io'],
            'exports': 'io'
        },
        'angularFileUpload': {
            'deps': ['angular']
        },
        'leaflet': {
            'exports': 'L'
        },
        'leaflet-directive': {
            'deps': ['angular']
        }
    }
});

require([
  'angular',
  'app',
  'bootstrap',
  'ngSails',
  'ui.bootstrap',
  'angularFileUpload',
  'leaflet-directive',
  'leaflet'
], function (angular, app) {

    angular.element(document.getElementsByTagName('html')[0]);

    angular.element().ready(function () {
        angular.resumeBootstrap([app.name]);
    });

});

App.js


define([
  'angular',
  'sails.io',
  'controllers',
  'ngSails',
  'ui.bootstrap',
  'angularFileUpload',
  'leaflet-directive',
  'leaflet'
], function (angular, io) {

  var socket = io.connect(), app;

  socket.on('connect', function socketConnected() {
    console.log('Socket is now connected.');
  });

  app = angular.module('consensus', [
    'controllers','ngSails','ui.bootstrap','angularFileUpload','leaflet-directive'
  ]);

  return app;

});
mourner commented 9 years ago

This is not a support forum, it's a place to report Leaflet issues. Please try asking for help on the forum instead https://groups.google.com/forum/#!forum/leaflet-js