项目初始化
mkdir new-project
cd new-project
npm init
npm install ol
npm install --save-dev parcel-bundler
JS和HTML
//index.js
import 'ol/ol.css';
import {Map ,View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
const map = new Map({
target:'map',
layers:[
new TileLayer({
source:new OSM()
})
],
view:new View({
center:[0,0],
zoom:0
})
});
<!--index.html-->
<!DOCTYPE html>
<html&g