如何在codeigniter中使用Openlayers3库文件查看文件
How to use Openlayers3 library files in codeigniter View files
我正在尝试在我的 codeigniter 中使用 openlayers 在用户访问某个地方时显示一些地图信息。
但是我卡在了初级阶段。我知道这是一个愚蠢的问题,但我确实需要使用它。
我可以在 main.js 上使用 Vector、GeoJSON 等 Openlayer 库,正如 运行 node.js 在他们的网站上提到的那样。
但在 codeignite 中我想在特定的视图页面中使用它。那么如何在特定的视图页面中导入这些js文件。
假设我在 root foler 中有我的 openlayer 模块
Like
Porject
-- Application
-- openlayers_modules
// which have ol folder inside it.
-- system
-- stylesheets
-- index.php
通常情况下,我们将其用作index.html和main.js,两者都在根文件夹中。
我有点困惑如何使用它。
如果我在视图文件中使用这些 js 文件,例如:lightning.php 那么它会显示为
<script type="text/javascript">
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import VectorLayer from 'ol/layer/Vector.js';
import VectorSource from 'ol/source/Vector.js';
import {Fill, Stroke, Style, Text} from 'ol/style.js';
Uncaught SyntaxError: Unexpected identifier
所以我的问题是我们如何在带有或不带有节点 js 的 codeigniter 应用程序中的特定视图页面上实现它。
感谢您的帮助。谢谢
我无法在 node.js 方面帮助你。但是你可以在不使用节点的情况下做到这一点。只需 link 带有 cdn 的 openalyer 就可以了。
<link rel="stylesheet" href="https://openlayers.org/en/v3.20.1/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v3.20.1/build/ol.js"></script>
但是你不能使用最新版本的openlayer。而且代码也有点 different.i.e:
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
使用此 link 查找所有示例
我正在尝试在我的 codeigniter 中使用 openlayers 在用户访问某个地方时显示一些地图信息。
但是我卡在了初级阶段。我知道这是一个愚蠢的问题,但我确实需要使用它。
我可以在 main.js 上使用 Vector、GeoJSON 等 Openlayer 库,正如 运行 node.js 在他们的网站上提到的那样。
但在 codeignite 中我想在特定的视图页面中使用它。那么如何在特定的视图页面中导入这些js文件。
假设我在 root foler 中有我的 openlayer 模块
Like
Porject
-- Application
-- openlayers_modules
// which have ol folder inside it. -- system
-- stylesheets
-- index.php
通常情况下,我们将其用作index.html和main.js,两者都在根文件夹中。
我有点困惑如何使用它。
如果我在视图文件中使用这些 js 文件,例如:lightning.php 那么它会显示为
<script type="text/javascript">
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import VectorLayer from 'ol/layer/Vector.js';
import VectorSource from 'ol/source/Vector.js';
import {Fill, Stroke, Style, Text} from 'ol/style.js';
Uncaught SyntaxError: Unexpected identifier
所以我的问题是我们如何在带有或不带有节点 js 的 codeigniter 应用程序中的特定视图页面上实现它。
感谢您的帮助。谢谢
我无法在 node.js 方面帮助你。但是你可以在不使用节点的情况下做到这一点。只需 link 带有 cdn 的 openalyer 就可以了。
<link rel="stylesheet" href="https://openlayers.org/en/v3.20.1/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v3.20.1/build/ol.js"></script>
但是你不能使用最新版本的openlayer。而且代码也有点 different.i.e:
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
使用此 link 查找所有示例