未加载 Leaflet MarkerCluster 插件的 CSS 和 JS 文件的本地引用
Local References to CSS and JS files for Leaflet MarkerCluster plugin not loading
目前,我正在使用 cloudflare 的 cdnjs 来引用 MarkerCluster 插件 js 和 css 传单文件,它工作正常。但是,当我尝试引用从 github 页面下载的本地版本并重新加载我的 html 页面时,markerclusters 消失了。这是我的参考资料:
<link rel="stylesheet" type="text/css" href="Leaflet.markercluster-master/Leaflet.markercluster-master/dist/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="Leaflet.markercluster-master/Leaflet.markercluster-master/dist/MarkerCluster.Default.css" />
<script src="Leaflet.markercluster-master/Leaflet.markercluster-master/src/MarkerCluster.js"></script>
我检查并重新检查了文件路径,我可以确认它们是正确的。我已经引用了 MarkerCluster.css 和 MarkerCluster.Default.css,因为当我通过 cdnjs 引用时推荐这样做。我已确保从 github 重新下载最新版本,但仍然无济于事。
我已经从运行 js 文件的脚本中添加和删除了 type="text/javascript",但这也没有帮助:
<script type="text/javascript" src="Leaflet.markercluster-master/Leaflet.markercluster-master/src/MarkerCluster.js"></script>
我在 html 文件的 <head>
中引用了这些文件。任何帮助将不胜感激!
推理:
我想引用本地文件,以便它可以在 cdnjs 出现故障时充当备份。我知道这种情况很少发生,如果有的话。但是对于这个项目,我们关心的是长期维护这个站点,并希望确保最大限度地防止插件breaking/becoming不兼容。
如果您查看 dist/WhereAreTheJavascriptFiles.txt
,您会发现如果您下载源代码,您需要使用 jake 构建 dist js 文件。或者只使用 CDN。您包含的 js 文件是源代码库的一部分。
您下载的MarkerCluster.js
文件只是插件源代码的一部分。
它与其他源文件连接生成 dist
文件,可在 public CDN 上获得。
查看存储库中的免责声明:https://github.com/Leaflet/Leaflet.markercluster/blob/master/dist/WhereAreTheJavascriptFiles.txt
We don't ship the .js files in the git master branch.
They are only present in version tags and in npm.
See how to get the JS files here: https://github.com/Leaflet/Leaflet.markercluster#using-the-plugin
Or how to build them: https://github.com/Leaflet/Leaflet.markercluster#building-testing-and-linting-scripts
检索此 dist JS 文件的一种非常简单的方法是下载从 CDN 获得的内容。例如。在浏览器地址栏中粘贴 URL;这应该显示文件的原始内容。然后右键单击代码的任意位置并 select "Save as..."
目前,我正在使用 cloudflare 的 cdnjs 来引用 MarkerCluster 插件 js 和 css 传单文件,它工作正常。但是,当我尝试引用从 github 页面下载的本地版本并重新加载我的 html 页面时,markerclusters 消失了。这是我的参考资料:
<link rel="stylesheet" type="text/css" href="Leaflet.markercluster-master/Leaflet.markercluster-master/dist/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="Leaflet.markercluster-master/Leaflet.markercluster-master/dist/MarkerCluster.Default.css" />
<script src="Leaflet.markercluster-master/Leaflet.markercluster-master/src/MarkerCluster.js"></script>
我检查并重新检查了文件路径,我可以确认它们是正确的。我已经引用了 MarkerCluster.css 和 MarkerCluster.Default.css,因为当我通过 cdnjs 引用时推荐这样做。我已确保从 github 重新下载最新版本,但仍然无济于事。
我已经从运行 js 文件的脚本中添加和删除了 type="text/javascript",但这也没有帮助:
<script type="text/javascript" src="Leaflet.markercluster-master/Leaflet.markercluster-master/src/MarkerCluster.js"></script>
我在 html 文件的 <head>
中引用了这些文件。任何帮助将不胜感激!
推理: 我想引用本地文件,以便它可以在 cdnjs 出现故障时充当备份。我知道这种情况很少发生,如果有的话。但是对于这个项目,我们关心的是长期维护这个站点,并希望确保最大限度地防止插件breaking/becoming不兼容。
如果您查看 dist/WhereAreTheJavascriptFiles.txt
,您会发现如果您下载源代码,您需要使用 jake 构建 dist js 文件。或者只使用 CDN。您包含的 js 文件是源代码库的一部分。
您下载的MarkerCluster.js
文件只是插件源代码的一部分。
它与其他源文件连接生成 dist
文件,可在 public CDN 上获得。
查看存储库中的免责声明:https://github.com/Leaflet/Leaflet.markercluster/blob/master/dist/WhereAreTheJavascriptFiles.txt
We don't ship the .js files in the git master branch. They are only present in version tags and in npm.
See how to get the JS files here: https://github.com/Leaflet/Leaflet.markercluster#using-the-plugin Or how to build them: https://github.com/Leaflet/Leaflet.markercluster#building-testing-and-linting-scripts
检索此 dist JS 文件的一种非常简单的方法是下载从 CDN 获得的内容。例如。在浏览器地址栏中粘贴 URL;这应该显示文件的原始内容。然后右键单击代码的任意位置并 select "Save as..."