Toggle navigation
Wialon Playground
Add library
jQuery latest
Bootstrap 3.3.1
Wialon Javascript SDK
Run
Get code
Fork
Save
Examples
Login
Get units
Change unit icon
Get messages
Get sensors
Edit sensors
Commands
Monitoring notification
Track layer
Get resources
Resources and accounts
Account parameters
Do payment
Management Driver
Create notification
Get geofences
Geofence parameters
Create geofence
Gurtam map
Units on map
Unit trace
Create report template
Execute report
Execute custom report
Create driver
Bind driver to unit
Unit edit fields
Import fillings
Token login for site
Advanced authorization form
Token usage in app
Account hierarchy
Nearest units
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Wialon Playground - Gurtam map</title> <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="https://hst-api.wialon.com/wsdk/script/wialon.js"></script> </head> <body> <!-- load map --> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.2/leaflet.css" /> <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.2/leaflet.js"></script> <div id="map"></div> </body> </html>
HTML
#map{ width:500px; height:400px; }
CSS
function initMap() { L.TileLayer.WebGis = L.TileLayer.extend({ initialize: function (url, options) { options = L.setOptions(this, options); if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) { options.tileSize = Math.floor(options.tileSize / 2); options.zoomOffset++; if (options.minZoom > 0) { options.minZoom--; } this.options.maxZoom--; } if (options.bounds) { options.bounds = L.latLngBounds(options.bounds); } this._url = url + "/gis_render/{x}_{y}_{z}/" + options.userId + "/tile.png"; var subdomains = this.options.subdomains; if (typeof subdomains === 'string') { this.options.subdomains = subdomains.split(''); } }, getTileUrl: function (tilePoint) { return L.Util.template(this._url, L.extend({ s: this._getSubdomain(tilePoint), z: 17 - this._map._zoom, x: tilePoint.x, y: tilePoint.y }, this.options)); } }); L.tileLayer.webGis = function (url, options) { return new L.TileLayer.WebGis(url, options); }; // create a map in the "map" div, set the view to a given place and zoom var map = L.map('map').setView([54.68, 25.27], 10); // add an Gurtam Maps tile layer L.tileLayer.webGis(wialon.core.Session.getInstance().getBaseGisUrl('render'), { attribution: 'Gurtam Maps', minZoom: 4, userId: wialon.core.Session.getInstance().getCurrUser().getId() }).addTo(map); } // execute when DOM ready $(document).ready(function () { wialon.core.Session.getInstance().initSession("https://hst-api.wialon.com"); // init session // For more info about how to generate token check // http://sdk.wialon.com/playground/demo/app_auth_token wialon.core.Session.getInstance().loginToken("5dce19710a5e26ab8b7b8986cb3c49e58C291791B7F0A7AEB8AFBFCEED7DC03BC48FF5F8", "", // try to login function (code) { // login callback // if error code - print error message if (code) { return; } initMap(); }); });
JS
Result
Source code of example
Close ✕
×
Source code