如何在 asp.net mvc 中加载 geojson 文件
How to load geojson file in asp.net mvc
我一直在我的 cshtml 页面中添加以下文件。
<script src="http://code.highcharts.com/maps/highmaps.js" )"></script>
<script src="https://code.highcharts.com/maps/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/drilldown.js"></script>
<script src="~/Content/js/balochistan.geojson"></script>
并且 higmaps 的代码与脚本标签存在于同一页面上。一切正常,但 hte 地图未显示,并且未加载 geojson 文件时出错。
http://localhost:9090/Content/js/balochistan.geojson net::ERR_ABORTED 404 (Not Found)
谁能帮忙说明如何正确加载 geojson 文件以及如何正确为其提供静态路径?
无法以 .geojson
结尾的文件加载 - 作为脚本 - 因为它是 json 文件
添加此文件是一组 json 数据 - 您需要将它们加载到 highcharts
上,或者使用 ajax 加载,或者在开头将它们添加为变量并连接到图表。
已解决:
通过执行以下几个步骤解决了问题:
以正确的顺序添加脚本标签。
其次 highmaps.js 和 highcharts.js 文件在同一页面上使用时相互冲突。
为了解决此问题,您必须添加
<script src="http://code.highcharts.com/highcharts-more.js"></script>
除了 highcharts.js 之外的脚本标签,还将 highmaps.js 替换为:
<script src="//code.highcharts.com/maps/modules/map.js"></script>
像这样:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="//code.highcharts.com/maps/modules/map.js"></script>
这解决了我的问题,现在正在显示地图。
我一直在我的 cshtml 页面中添加以下文件。
<script src="http://code.highcharts.com/maps/highmaps.js" )"></script>
<script src="https://code.highcharts.com/maps/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/drilldown.js"></script>
<script src="~/Content/js/balochistan.geojson"></script>
并且 higmaps 的代码与脚本标签存在于同一页面上。一切正常,但 hte 地图未显示,并且未加载 geojson 文件时出错。
http://localhost:9090/Content/js/balochistan.geojson net::ERR_ABORTED 404 (Not Found)
谁能帮忙说明如何正确加载 geojson 文件以及如何正确为其提供静态路径?
无法以 .geojson
结尾的文件加载 - 作为脚本 - 因为它是 json 文件
添加此文件是一组 json 数据 - 您需要将它们加载到 highcharts
上,或者使用 ajax 加载,或者在开头将它们添加为变量并连接到图表。
已解决: 通过执行以下几个步骤解决了问题: 以正确的顺序添加脚本标签。 其次 highmaps.js 和 highcharts.js 文件在同一页面上使用时相互冲突。 为了解决此问题,您必须添加
<script src="http://code.highcharts.com/highcharts-more.js"></script>
除了 highcharts.js 之外的脚本标签,还将 highmaps.js 替换为:
<script src="//code.highcharts.com/maps/modules/map.js"></script>
像这样:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="//code.highcharts.com/maps/modules/map.js"></script>
这解决了我的问题,现在正在显示地图。