Guest User

Untitled

a guest
Jan 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. leaflet.js:6 Uncaught TypeError: Cannot read property 'call' of undefined
  2. at e.whenReady (leaflet.js:6)
  3. at e.addLayer (leaflet.js:6)
  4. at HTMLDivElement.<anonymous> (Leaflet.html:62)
  5. at HTMLDivElement.dispatch (jquery.min.js:3)
  6. at HTMLDivElement.q.handle (jquery.min.js:3)
  7.  
  8. leaflet.js:6 Uncaught TypeError: t.onRemove is not a function
  9. at e.removeLayer (leaflet.js:6)
  10. at HTMLDivElement.<anonymous> (Leaflet.html:60)
  11. at HTMLDivElement.dispatch (jquery.min.js:3)
  12. at HTMLDivElement.q.handle (jquery.min.js:3)
  13.  
  14. leaflet.js:6 Uncaught TypeError: t.onRemove is not a function
  15. at e.removeLayer (leaflet.js:6)
  16. at HTMLDivElement.<anonymous> (Leaflet.html:60)
  17. at HTMLDivElement.dispatch (jquery.min.js:3)
  18. at HTMLDivElement.q.handle (jquery.min.js:3)
  19.  
  20. <button id="blank><a href="index_blank.html">
  21.  
  22. <!DOCTYPE html>
  23. <html>
  24. <head>
  25. <title>Leaflet Loading GeoJSON</title>
  26.  
  27. <meta charset="UTF-8">
  28. <link rel="stylesheet" href="css/layerbutton.css" />
  29. <link rel="stylesheet" href="leaflet/leaflet.css" />
  30. <link href='http://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet'
  31. text='text/css'>
  32. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
  33.  
  34. </head>
  35. <body>
  36. <h1>My map</h1>
  37. <div id='mapdiv' style='height:500px;'>here lies a map.</div>
  38. <div id="tileBar">
  39. <div class="layerButt" id="pointButt"><h3> TTC On/Off</h3></div>
  40. </div>
  41. <script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js"></script>
  42. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  43. <script src="js/ttc.js"></script>
  44.  
  45. <script>
  46. // <script> powers up script
  47. var mymap = L.map('mapdiv').setView([43,-79],8);
  48.  
  49. L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v10/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1Ijoic3BhdGlhbGFydHMiLCJhIjoiY2l3c2NlcnJkMTR1YTJ5dGJzYTJuZ3oyMSJ9.qIr2uFfZbZzrDHaJBccYeQ', {
  50. attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
  51. minZoom: 6,
  52. maxZoom: 16,
  53. //choose project id/dataset from map box studio
  54. id: 'n/a,(and chose not to add this, the tile layer opens )
  55. //accessToken id from map box account
  56. accessToken: n/a (I chose not to add this, the tile layer does open)
  57.  
  58. }).addTo(mymap);
  59.  
  60. function attach (feature,layer) {
  61. layer.bindPopup("<h1 class='infoHeader'> Toronto TTC Subway Name</h1><p class='infoHeader'>" + feature.properties.SBWAY_NAME +"</p>");
  62. };
  63.  
  64. L.geoJSON(ttc,{
  65.  
  66. onEachFeature: attach
  67.  
  68. }).addTo(mymap);
  69.  
  70.  
  71. // closes script
  72. </script>
  73.  
  74. <script>
  75.  
  76. $("#pointButt").click(function(){
  77.  
  78. if(mymap.hasLayer(ttc)){
  79. mymap.removeLayer(ttc);
  80. } else {
  81. mymap.addLayer(ttc);
  82. };
  83.  
  84. });
  85.  
  86. </script>
  87.  
  88. html, body, #mapdiv{
  89. height: 100%;
  90. width: 100%;
  91. }
  92.  
  93. .layerButt{
  94. padding: 5px;
  95. background-color: orange;
  96. color: black;
  97. font-size: 22px;
  98. font-family: Roboto Slab;
  99. width: auto;
  100. height: auto;
  101. cursor: pointer;
  102. margin: 5px;
  103. }
  104.  
  105. #tileBar {
  106. height: auto;
  107. width: 100%;
  108. position: absolute;
  109. top:0;
  110. background-color: black;
  111. }
Add Comment
Please, Sign In to add comment