Map data
Map server
JS library
Browser
An opensource javascript library to load, display and render maps from multiple sources on web pages
An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps
Size of minified JS file
Number of classes/namespaces
Unminified file
465.3 KB
163
3.5 MB*
126.5 KB
52
223.6 KB
*due to dependency to Closure Library
Example
Require plugins
Leaflet.Omnivore (data formats)
Leaflet.draw
Leaflet.markercluster
Leaflet.MapboxVectorTile
Built-in
L.GridLayer is a grid of <div>s or <canvas>s or <img>s
<!DOCTYPE html>
<html>
<head>
<title>Simple Openlayers Map</title>
<link rel="stylesheet" href="http://openlayers.org/en/v3.12.1/css/ol.css" type="text/css">
<script src="http://openlayers.org/en/v3.12.1/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM() })
],
target: 'map',
view: new ol.View({
projection: ol.proj.get('EPSG:4326'),
center: [101.4603,2.9588],
zoom: 10})
});
</script>
</body>
</html><!DOCTYPE html>
<html>
<head>
<title>Simple Leaflet Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
</head>
<body>
<div id="map" style="width: 600px; height: 400px"></div>
<script>
var map = L.map('map').setView([2.9588,101.4603], 10);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © ' + mapLink,
maxZoom: 18,
}).addTo(map);
</script>
</body>
</html>var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM() })
],
target: 'map',
view: new ol.View({
projection: ol.proj.get('EPSG:4326'),
center: [101.4603,2.9588],
zoom: 10})
});var map = L.map('map').setView([2.9588,101.4603], 10);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © ' + mapLink,
maxZoom: 18,
}).addTo(map);class constructors style
object factories style
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([101.4603,2.9588]),
});
var iconStyle = new ol.style.Style({
image: new ol.style.Icon( ({
src: 'http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/img/mobile-loc.png'
}))
});
iconFeature.setStyle(iconStyle);
var vectorSource = new ol.source.Vector({
features: [iconFeature]
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM() }),
vectorLayer
],
target: 'map',
view: new ol.View({
projection: ol.proj.get('EPSG:4326'),
center: [101.4603,2.9588],
zoom: 10})
});var map = L.map('map').setView([2.9588,101.4603], 10);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © ' + mapLink,
maxZoom: 18,
}).addTo(map);
var marker = L.marker([2.9588,101.4603])
.addTo(map);// create icon feature
// 2 lines of codes
// define style for icon
// 3 lines of codes
// set icon style
// create popup div element for popup
// 10 lines of codes
// define style for popup
// 5-10 lines of codes
// define popup behavior (show, hide, close etc)
// 10-15 lines of codes
// bind popup to icon
// 3 lines of codes
// create and set vector layer for icon
// 4 lines of codes
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM() }),
vectorLayer
],
target: 'map',
view: new ol.View({
projection: ol.proj.get('EPSG:4326'),
center: [101.4603,2.9588],
zoom: 10})
});var map = L.map('map').setView([2.9588,101.4603], 10);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © ' + mapLink,
maxZoom: 18,
}).addTo(map);
var marker = L.marker([2.9588,101.4603])
.addTo(map)
.bindPopup("<b>Hello!</b><br>I am a popup!")
.openPopup();Customer requests assistance to display Smartmap API on their website with marker pointing location of their stores. Which map library should be sufficient to fulfill the requirement?
The new TMOM Mobile would like to implement similar feedback function like TMOM Web which allow users to draw point, line or polygon on a desired area. Which map library should be sufficient to fulfill the requirements?