{"id":1126,"date":"2015-04-25T12:23:50","date_gmt":"2015-04-25T10:23:50","guid":{"rendered":"http:\/\/www.speich.net\/articles\/?p=1126"},"modified":"2019-10-06T10:09:28","modified_gmt":"2019-10-06T08:09:28","slug":"how-to-load-leaflet-js-and-leaflet-plugins-with-dojo-amd","status":"publish","type":"post","link":"https:\/\/www.speich.net\/articles\/en\/2015\/04\/25\/how-to-load-leaflet-js-and-leaflet-plugins-with-dojo-amd\/","title":{"rendered":"How to load leaflet.js and leaflet plugins with dojo AMD"},"content":{"rendered":"\n<pre><code class=\"language-javascript\">&lt;script type=\"text\/javascript\"&gt;\nvar dojoConfig = {\n  baseUrl: '\/lib',\n  async: true,\n  packages: [\n    {name: 'Leaflet', location: '.\/Leaflet'}\n  ],\n  map: {\n    \/\/ lets you switch between minified and source version of leaflet for development\n    '*': {\n      'Leaflet\/leaflet': 'Leaflet\/leaflet-src'\n    }\n  }\n};\n&lt;\/script&gt;\n&lt;script type=\"text\/javascript\" src=\"lib\/dojo\/dojo.js\"&gt;&lt;\/script&gt;\n\n&lt;script type=\"text\/javascript\"&gt;\nrequire([\n  'require',\n  'Leaflet\/leaflet'\n], function(require, L) {\n\n  \/\/ load plugin after loading leaflet, because it's referenced by the draw plugin\n  require(['Leaflet\/plugins\/draw\/leaflet.draw'], function() {\n\n    var drawControl = new L.Control.Draw({...}),\n    map = L.map(...);\n    ...\n\n  }):\n});\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;script type=&#8221;text\/javascript&#8221;&gt; var dojoConfig = { baseUrl: &#8216;\/lib&#8217;, async: true, packages: [ {name: &#8216;Leaflet&#8217;, location: &#8216;.\/Leaflet&#8217;} ], map: { \/\/ lets you switch between minified and source version of leaflet for development &#8216;*&#8217;: { &#8216;Leaflet\/leaflet&#8217;: &#8216;Leaflet\/leaflet-src&#8217; } } }; &lt;\/script&gt; &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;lib\/dojo\/dojo.js&#8221;&gt;&lt;\/script&gt; &lt;script type=&#8221;text\/javascript&#8221;&gt; require([ &#8216;require&#8217;, &#8216;Leaflet\/leaflet&#8217; ], function(require, L) { \/\/ load plugin &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.speich.net\/articles\/en\/2015\/04\/25\/how-to-load-leaflet-js-and-leaflet-plugins-with-dojo-amd\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to load leaflet.js and leaflet plugins with dojo AMD&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,26,29,51],"class_list":["post-1126","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-amd","tag-dojo","tag-dojotolkit","tag-leaflet-js","entry"],"_links":{"self":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/comments?post=1126"}],"version-history":[{"count":1,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1126\/revisions"}],"predecessor-version":[{"id":1662,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/posts\/1126\/revisions\/1662"}],"wp:attachment":[{"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/media?parent=1126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/categories?post=1126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.speich.net\/articles\/wp-json\/wp\/v2\/tags?post=1126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}