- Kotlin Blueprints
- Ashish Belagali Hardik Trivedi Akshay Chordiya
- 233字
- 2021-07-02 21:50:16
Rendering the map
The ol is the OpenLayers package that provides the API to play with the maps overlay.
ol.Maps
The core essential component of the ol package is ol.Maps. It is used to render the maps on the target p, which in our case is map-overlay a p tag from index.html where the map will be shown:
// Renders the map on the target p
var map = new ol.Map({target: "map"})
ol.View
This is used to manage or configure the viewing properties of the map such as zoom level, default center position, and the projection of the map:
// To configure center, zoom level and projection of the map
var view = new ol.View({
zoom: 9
});
ol.layer
A layer is a visual representation of data from a source. It is used to show the data on the map that is fetched from remote sources.
It has three basic types of layers:
- ol.layer.Tile: This is for layer sources that provide pre-rendered, tiled images in grids that are organized by zoom levels for specific resolutions
- ol.layer.Image: This is for server rendered images
- ol.layer.Vector: This is for vector data that is rendered client-side
Layers are set when configuring the map object:
layers: [
new ol.layer.Tile(...)
],
ol.source
This is used to set the source of the remote data for the layer:
layers: [
new ol.layer.Tile({source: new ol.source.OSM()})
]
推薦閱讀
- Android和PHP開發最佳實踐(第2版)
- Java FX應用開發教程
- Data Analysis with IBM SPSS Statistics
- Rust Cookbook
- Python王者歸來
- Java Web開發技術教程
- 小程序開發原理與實戰
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(高級進階篇)
- Spring Boot進階:原理、實戰與面試題分析
- Mastering JavaScript Design Patterns(Second Edition)
- Lighttpd源碼分析
- Mastering Git
- Web前端應用開發技術
- 零基礎學C語言(第4版)
- 玩轉.NET Micro Framework移植:基于STM32F10x處理器