1

I'm trying to get the basic map to show on my page and all I get is a blank page.

This is my html:

    <!DOCTYPE html>
    <html ng-app="example">
    <head>
      <meta charset="utf-8">
      <title>example</title>
      <script src="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.js"></script>
      <script src="js/angular.js"></script>
      <script src="js/angular-leaflet-directive.js"></script>
      <script src="js/angular-ui-router.js"></script>
      <script src="js/frontend.js"></script>
      <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.css">
      <link rel="stylesheet" href="style.css">
   </head>
   <body ng-controller="SimpleMapController">
     hello there
     <leaflet></leaflet>
   </body>
  </html>

My javascript code:

var app = angular.module('example', ['leaflet-directive']);

app.controller("SimpleMapController", [ '$scope', function($scope) {
    angular.extend($scope, {
        defaults: {
            scrollWheelZoom: false
        }
    });
}]);

This is pretty much exactly as it is explained in the (poorly explained) example. Yet, instead of a map (like in their example), I have a blank screen. On the dev console of the browser I get the following error as well:

GET file://b.tile.openstreetmap.org/1/0/1.png net::ERR_FILE_NOT_FOUND

It looks like it's looking for the map pngs on my end when it should be getting them from leaflet. Am I missing something in my html or the js?

mwdowns
  • 75
  • 1
  • 2
  • 8
  • 1
    you **MUST** include a `height` and `width` for the leaflet directive. – Claies Dec 20 '16 at 16:48
  • Thank you. Why do they not specify that on the angular leaflet directive page? Seems like that's pretty important info. – mwdowns Dec 20 '16 at 16:51
  • 1
    they do basically mention it, but it's not really highlighted, https://github.com/tombatossals/angular-leaflet-directive#center – Claies Dec 20 '16 at 16:55
  • 1
    Yeah, I think I saw that it my searching but missed it's importance. They really should put it on their examples page, because as of now it says all you need is in the html. – mwdowns Dec 20 '16 at 16:59
  • yeah, the "adding the custom tag `` with some attributes on your HTML code" is kinda vague; might be worth putting an issue in the GitHub about it.... – Claies Dec 20 '16 at 17:02

0 Answers0