vectormap-js-dev
v2.0.0-beta008
Published
openlayers mapsuite
Downloads
41
Maintainers
Readme
MapSuite
The mapsuite-vectormap.js is an open-source JavaScript SDK and an extension of OpenLayers to create maps for web and mobile devices. With the help of Map Suite vector styling schema - StyleJSON, you can easily create beautiful maps for your application.
With Map Suite VectorMap.js, you will have full access to OpenLayers, as well as any plugins or extensions created based on OpenLayers, for example, the "3rd party libraries" published on https://openlayers.org. With the help of them, you can easily create any styled map and put it anywhere, and build a customized geocoding or routings from other providers.
Wiki Documentation: http://wiki.thinkgeo.com/wiki/map_suite_api
- Getting started with Map Suite VectorMap.js
- Community & Support
- API documentation
- Predefined open source styles
- Map Suite Vector StyleJSON Specification
- World Streets Data Schema
Light Map Style
Dark Map Style
Hybrid Map Style
Install
The official guide assumes intermediate level knowledge of HTML, CSS, and JavaScript, and have some experience of any front-end development editor, such as Visual Studio Code, Webstorm, Sublime Text or some similars. if you are totally new to frontend development, the easiest way to try out this library is using the "OpenCodePen Hello World exampleLayers". Feel free to open it in another tab and follow along as we go through some features.
2 options of installing Map Suite VectorMap.js:
- Use NPM install
npm install vectormap-js
or
npm install vectormap-js-dev
- Include related in
<!-- style sheet for vectormap.js -->
<link rel="stylesheet" href="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.css"></link>
<!-- latest minified version of vectormap.js -->
<script src="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.js"></script>
Get Started
Set up a basic map with VectorMap.js in 6 steps (here take Visual Studio Code for example).
Step 1. Create a html page with name "index.html "
Step 2. In the <head>
of your HTML page, import the vectormap.js and related css file.
<!-- style sheet for vectormap.js -->
<link rel="stylesheet" href="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.css"></link>
<!-- latest minified version of vectormap.js -->
<script src="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.js"></script>
And add a height and width for the map:
<style>
#map {
width: 800px;
height: 600px;
}
</style>
Step 3. In the <body>
of your HTML page, add a "map"
div.
<div id="map"></div>
Step 4. At the bottom of the html page, add a JavaScript section to create an instance of map control, and add the vector layer.
<script>
var worldStreetsLayer = new ol.mapsuite.VectorTileLayer("thinkgeo-world-streets-light.json",
{
'apikey':'your-thinkgeo-gis-service-vector-tile-key'
});
let map = new ol.Map({
layers: [worldStreetsLayer],
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([-96.79620, 32.79423]),
zoom: 2,
}),
});
</script>
NOTE: Please check here on how to create your own ThinkGeo GIS Service Vector Tile key
.
Step 5. Download one of Predefined open source styles and copy it to the directory where the index.html is. For example, we can call it "thinkgeo-world-streets-light.json".
After all the above steps completed, your HTML page should be:
<!DOCTYPE html>
<html>
<head>
<title>Sample Map</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.css" type="text/css">
<script src="https://cdn.thinkgeo.com/vectormap/0.1.0/mapsuite-vectormap.js"></script>
<style>
#map {
width: 800px;
height: 600px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var worldStreetsLayer = new ol.mapsuite.VectorTileLayer("thinkgeo-world-streets-light.json",
{
'apikey':'your-thinkgeo-gis-service-vector-tile-key'
});
let map = new ol.Map({
layers: [worldStreetsLayer],
target: 'map',
view: new ol.View({
center: ol.proj.fromLonLat([-96.79620, 32.79423]),
zoom: 2,
}),
});
</script>
</body>
</html>
Step 6. Run the page and a beautiful map there.
NOTE:
ThinkGeo Icon FontSet is an icon set, which is used in "Predefined open source styles" as POI icons. If you are using ready-to-go predefined styleJSON file downloaded, please add following code in "<Head>"
.
<script src="https://cdn.thinkgeo.com/icons-font/0.1.0/webfontloader.js"></script>
<script>
WebFont.load({
custom: {
families: ["ThinkgeoFont"],
urls: ["https://cdn.thinkgeo.com/icons-font/0.1.0/thinkgeo-font.css"]
}
});
</script>
Vector Tiles
Besides loading the traditional KML, GeoJSON, bitmap tiles etc., Map Suite vectormap.js draws its own tiles from vector tiles that contains the source data.
Map Suite GIS Service provides a free vector tile service (*.mvt) based on open data from OpenStreetMap, Natural Earth and some other data providers, with global coverage updated continuously. - sign up for an API Key here.
Styling
Map Suite vector styling schema - Vector StyleJSON is designed for you to specify data sources, layers and how to define and apply styles to layers. Please check the demo from "Predefined open source styles" or check related documentation at https://thinkgeo.gitbooks.io/map-suite-stylejson-specification/content/.
Browser Suport
mapsuite-vectormap.js is officially supported and tested on the last two versions of these browsers:
- Mac OS: Chrome, Firefox, and Safari
- Windows: Chrome, Firefox, IE11, and IE Edge
- iOS: Safari, Chrome, Firefox
- Android: Chrome
mapsuite-vectormap.js should also run in any brower with HTML5 support.
License
mapsuite-vectormap.js is licensed under the Apache 2.0.