Warning:
Fullscreen sub-module uses HTML5 fullscreen API that may not be supported by all browsers.
Gets options and returns map object.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before loading map. | 
| after | Function | function(){} | A task to be executed after loading map. | 
| mode | String | production | Defines app environment. Predefined values are: 'development', 'test' and 'production' | 
| element | CSS selector | #map | A CSS selector to select map element with. | 
| boxZoom | Boolean | false | Whether or not users can be able to use mouse to select a rectangle while holding keyboard Shift in order to zoom. | 
| minZoom | Integer | 1 | Minimum map zoom level. | 
| maxZoom | Integer | 18 | Maximum map zoom level. | 
| presets | Object | { latlng: { lat: 32, lng: 52 }, zoom: 6 } | Map view first load state. | 
| i18n | i18n object | {} | Language key:values for multi-lingual apps. (read more) | 
var map = $.sMap({
	before: function() {
		console.log('Before');
	},
	after: function() {
		console.log('After');
	},
	mode: 'development',
	element: '#my-map',
	boxZoom: true,
	minZoom: 3,
	maxZoom: 15,
	presets: {
		latlng: {
			lat: 32,
			lng: 52,
		},
		zoom: 8,
	},
	i18n: {
		fa: {
			'custom-site-title': 'نقشه',
		},
		en: {
			'custom-site-title': 'Map',
		},
		ar: {
			'custom-site-title': 'خريطة',
		},
	},
});
									Gets options and appends company logo to map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| url | URL | Logo image URL. | 
$.sMap.logo.implement({
	url: env.url.domain + '/assets/images/site-logo.png',
});
									Implements fullscreen button to map view.
$.sMap.fullscreen.implement();
									Fullscreen sub-module uses HTML5 fullscreen API that may not be supported by all browsers.
Gets locale options and adds multi-lingual functionalities for selected languages to app.
| Property | Type | Default | Description | 
|---|---|---|---|
| locales | Array | ['fa', 'en', 'ar'] | Available languages are fa, en, and ar. | 
$.sMap.menu.implement();
$.sMap.locale.implement({
	locales: ['fa', 'en'],
});
									Gets an object of layers and loads up tiles onto map. Also impliments layer management options to menu automatically if $.sMap.menu.implement is already called.
| Property | Type | Default | Description | 
|---|---|---|---|
| server | URL | env.url.defaultBaselayer | |
| layers | String | Shiveh:ShivehGSLD256 | |
| format | mime type | image/png | |
| i18n | i18n key | site-default | 
$.sMap.layers.static.build({
	layers: {
		base: {
			default: {
				server: 'https://map.ir/shiveh',
				layers: 'Shiveh:ShivehGSLD256',
				format: 'image/png',
				i18n: 'custom-baselayer-default',
			},
			satellite: {
				server: 'https://demo.boundlessgeo.com/geoserver/ows?',
				layers: 'ne:ne',
				format: 'image/png',
				i18n: 'custom-baselayer-satellite',
			},
			terrain: {
				server: 'https://demo.boundlessgeo.com/geoserver/ows?',
				layers: 'nasa:bluemarble',
				format: 'image/png',
				i18n: 'custom-baselayer-terrain',
			},
		},
		over: {
			boundries: {
				server: 'https://korona.geog.uni-heidelberg.de/tiles/adminb/x={x}&y={y}&z={z}',
				i18n: 'custom-baselayer-boundries',
			},
			states: {
				server: 'https://{s}.tile.openstreetmap.se/hydda/roads_and_labels/{z}/{x}/{y}.png',
				i18n: 'custom-baselayer-states',
			},
		},
	},
});
									Appends the map zoom controller to the map view.
$.sMap.zoomControl.implement();
									Appends user location trigger button to the map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| history | Boolean | false | Whether user location should be added to search history or not. | 
$.sMap.userLocation.implement({
	history: true,
});
									userLocation uses the geolocation API of HTML5 to locate user location and only works on modern browsers that support this feature.
Newer modern browsers require a secure connection for this API to work.
Provides a handy way of accessing map location with a Copy button to save location to clipboard.
Appends sub-module's enterface to the map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| format | String | dms | Location format. Available values are 'dms' and 'latlng'. | 
| source | String | center | Location source. Available values are 'center', 'mouse', 'click' and 'contextmenu'. | 
$.sMap.dynamicLocation.implement({
	format: 'latlng',
	source: 'mouse',
});
									Enables hash url that is updated every time user moves the map or zooms in/out.
| Property | Type | Default | Description | 
|---|---|---|---|
| marker | Boolean | false | Whether or not center of the map is located with a marker when a map url is opened. | 
$.sMap.dynamicUrl({
	marker: true,
});
									dynamicUrl uses the pushState method of HTML5 history object to update browser's address bar every time users move the map or zoom in/out.
Enabling this feature on a map that is put in a news website, for example, might cause unwanted results. Imagine an article's url changing every time user moves the map!
Gets a map state and displays location address in a modal.
| Property | Type | Default | Description | 
|---|---|---|---|
| state | Object | Current map center | 
$.sMap.reverseGeocode.show({
	state: {
		latlng: {
			lat: 32,
			lng: 52,
		},
		zoom: 8,
	},
});
									Gets options and displays location address in marker popup.
| Property | Type | Default | Description | 
|---|---|---|---|
| state | Object | Current map center | |
| popup | Object | { title: { html: '', i18n: '', }, } | |
| icon | Object | icons.default.blue | 
$.sMap.reverseGeocode.mark({
	latlng: {
		lat: 32,
		lng: 52,
	},
	title: {
		html: 'Reverse Geocode',
		i18n: '',
	},
	icon: icons.default.blue,
});
									Gets no options and enables measurement options in contextmenu.
$.sMap.contextmenu.build({
	here: false,
	distance: true,
	area: true,
	copy: false,
	share: false,
	static: false,
});
$.sMap.measurement();
									Gets options and returns static map url.
| Property | Type | Default | Description | 
|---|---|---|---|
| state | Object | Current map state. | |
| width | Integer | 600 | |
| height | Integer | 400 | |
| label | String | ||
| color | String | red | Marker color. | 
$.sMap.staticMap.get({
	state: {
		latlng: {
			lat: 32,
			lng: 52,
		},
		zoom: 10,
	},
	width: 800,
	height: 600,
	label: 'My Location',
	color: 'green',
});
									| Property | Type | Default | Description | 
|---|---|---|---|
| Property | Type | Default | Description | 
$.sMap.staticMap.open({
	state: {
		latlng: {
			lat: 35.63665,
			lng: 51.45687,
		},
		zoom: 10,
	},
	width: 800,
	height: 600,
	label: 'My Location',
	color: 'green',
});
									Gets marker options, returns a marker object, and displays a marker on map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before marker creation. | 
| after | Function | function(){} | A task to be executed after marker creation. | 
| name | String (kebab-case) | temp | Marker name | 
| popup | Object | popup: { title: { html: '', i18n: '' }, description: { html: '', i18n: '' }, custom: false } | html can either be plain text or contain html tags. i18n is used for multi-lingual apps. If custom is set with a string, it will overwrite the automatically generated popup with your own content. There will be no popup if it's set to false. | 
| class | String | default | A CSS class with the prefix of feature-popup- is created from this value and is applied to marker popup's inner container. feature-popup-default for example if class is not set. | 
| latlng | Object | {} | Marker location. | 
| icon | Object | icons.default.blue | the icons object is defined in s.map.styles.js | 
| popupOpen | Boolean | false | Whether popup should be open when marker is created. | 
| pan | Boolean | false | Whether or not map should pan to marker location upon its creation. | 
| draggable | Boolean | false | Whether marker is or is not draggable. | 
| on | Object | { click: function(){}, contextmenu: function(){} } | Contains callback functions for click and contextmenu. | 
$.sMap.features();
$.sMap.features.marker.create({
	before: function() {
		console.log('Before');
	},
	after: function() {
		console.log('After');
	},
	name: 'my-marker',
	popup: {
		title: {
			html: 'Title',
			i18n: '',
		},
		description: {
			html: 'Description',
			i18n: '',
		},
		custom: false,
	},
	class: 'default',
	latlng: {lat: 32, lng: 52},
	icon: icons.default.blue,
	popupOpen: true,
	pan: false,
	draggable: true,
	on: {
		click: function(){
			console.log('click callback');
		},
		contextmenu: function(){
			console.log('contextmenu callback');
		},
	},
});
									Removes a marker programmatically.
$.sMap.features.marker.remove('my-marker');
									Removes all polygons from the map view.
$.sMap.features.marker.wipe();
									Gets polyline options, returns a polyline object and displays a polyline on map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before polyline creation. | 
| after | Function | function(){} | A task to be executed after polyline creation. | 
| name | String (kebab-case) | temp | Polyline name | 
| popup | Object | popup: { title: { html: '', i18n: '' }, description: { html: '', i18n: '' }, custom: false } | html can either be plain text or contain html tags. i18n is used for multi-lingual apps. If custom is set with a string, it will overwrite the automatically generated popup with your own content. There will be no popup if it's set to false. | 
| class | String | default | A CSS class with the prefix of feature-popup- is created from this value and is applied to polyline popup's inner container. feature-popup-default for example if class is not set. | 
| coordinates | Array | [] | Polyline's set of points. | 
| style | Object | styles.default.polyline | the styles object is defined in s.map.styles.js | 
| popupOpen | Boolean | false | Whether popup should be open when polyline is created. | 
| pan | Boolean | false | Whether or not map should pan to polyline location upon its creation. | 
| measurement | Boolean | false | Whether measurement info should to be displayed on polyline or not. | 
| on | Object | { click: function(){}, contextmenu: function(){} } | Contains callback functions for click and contextmenu. | 
$.sMap.features();
$.sMap.features.polyline.create({
	before: function() {},
	after: function() {},
	name: 'my-polyline',
	popup: {
		title: {
			html: 'Title',
			i18n: '',
		},
		description: {
			html: 'Description',
			i18n: '',
		},
		custom: false,
	},
	class: 'default',
	style: styles.default.polyline,
	coordinates: [
		[30, 50],
		[40, 57],
	],
	popupOpen: false,
	pan: false,
	measurement: false,
	on: {
		click: function(){
			console.log('click callback');
		},
		contextmenu: function(){
			console.log('contextmenu callback');
		},
	},
});
									Removes a polyline programmatically.
$.sMap.features.polyline.remove('my-polyline');
									Removes all polygons from the map view.
$.sMap.features.polyline.wipe();
									Gets polygon options, returns a polygon object and displays a polygon on map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before polygon creation. | 
| after | Function | function(){} | A task to be executed after polygon creation. | 
| name | String (kebab-case) | temp | Polygon name | 
| popup | Object | popup: { title: { html: '', i18n: '' }, description: { html: '', i18n: '' }, custom: false } | html can either be plain text or contain html tags. i18n is used for multi-lingual apps. If custom is set with a string, it will overwrite the automatically generated popup with your own content. There will be no popup if it's set to false. | 
| class | String | default | A CSS class with the prefix of feature-popup- is created from this value and is applied to polygon popup's inner container. feature-popup-default for example if class is not set. | 
| coordinates | Array | [] | Polygon's set of points. | 
| style | Object | styles.default.polygon | the styles object is defined in s.map.styles.js | 
| popupOpen | Boolean | false | Whether popup should be open when polygon is created. | 
| pan | Boolean | false | Whether or not map should pan to polygon location upon its creation. | 
| measurement | Boolean | false | Whether measurement info should to be displayed on polygon or not. | 
| on | Object | { click: function(){}, contextmenu: function(){} } | Contains callback functions for click and contextmenu. | 
$.sMap.features();
$.sMap.features.polygon.create({
	before: function() {},
	after: function() {},
	name: 'my-polygon',
	popup: {
		title: {
			html: 'Title',
			i18n: '',
		},
		description: {
			html: 'Description',
			i18n: '',
		},
		custom: false,
	},
	class: 'default',
	style: styles.default.polygon,
	coordinates: [
		[35, 55],
		[35, 45],
		[30, 55],
	],
	popupOpen: false,
	pan: false,
	measurement: false,
	on: {
		click: function(){
			console.log('click callback');
		},
		contextmenu: function(){
			console.log('contextmenu callback');
		},
	},
});
									Removes a polygon programmatically.
$.sMap.features.polygon.remove('my-polygon');
									Removes all polygons from the map view.
$.sMap.features.polygon.wipe();
									This sub-module must be called before using either of $.sMap.editor.points, $.sMap.editor.polylines, $.sMap.editor.polygons sub-modules.
| Property | Type | Default | Description | 
|---|---|---|---|
| renderer | string | 'svg' | Whether to use the canvas or svg tag to render shapes. Available values are 'canvas' and 'svg' | 
$.sMap.editor.implement();
									Gets an options object including a geoJSON, displays the set on the map upon start, and returns the points geoJSON.
| Property | Type | Default | Description | 
|---|---|---|---|
| geoJSON | geoJSON | { "type": "FeatureCollection", "features": [] } | |
| modules | Object | { create: false, edit: false, delete: false, get: false, editText: false, } | Choose which options are enabled/disabled for the set. | 
| on | Object | { click: false, contextmenu: false, create: function(){}, edit: function(){}, delete: function(){}, get: function(){}, editText: function(){}, } | An object of callback functions. | 
| icons | Array | [ { name: 'Blue', class: 'marker-blue', url: '/assets/images/marker-default-blue.svg', }, ] | An array of icons that is used to create Icon Gallery | 
$.sMap.editor.implement();
var points = {
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				title: 'Test1',
				description: 'Desc1',
				icon: '/assets/images/marker-default-green.svg',
			},
			"geometry": {
				"type": "Point",
				"coordinates": [52, 32]
			}
		},
		{
			"type": "Feature",
			"properties": {
				title: 'Test2',
				description: 'Desc2',
				icon: '/assets/images/marker-default-blue.svg',
			},
			"geometry": {
				"type": "Point",
				"coordinates": [53, 32]
			}
		},
		{
			"type": "Feature",
			"properties": {
				title: 'Test3',
				description: 'Desc3',
				icon: '/assets/images/marker-default-red.svg',
			},
			"geometry": {
				"type": "Point",
				"coordinates": [53, 33]
			}
		}
	]
};
points = $.sMap.editor.points.start({
	geoJson: points,
	modules: {
		create: true,
		drag: true,
		delete: true,
		get: true,
		editText: true,
		editIcon: true,
	},
	on: {
		click: function(feature){
			console.log('click');
			console.log(feature);
		},
		contextmenu: function(feature){
			console.log('contextmenu');
			console.log(feature);
		},
		change: function(){
			console.log($.sMap.editor.points.all());
		},
		create: function(point){
			console.log('create:');
			console.log(point);
		},
		drag: function(point){
			console.log('drag:');
			console.log(point);
		},
		delete: function(point){
			console.log('delete:');
			console.log(point);
		},
		get: function(point){
			console.log('get:');
			console.log(point);
		},
		editText: function(point){
			console.log('editText:');
			console.log(point);
		},
		editIcon: function(point){
			console.log('editIcon:');
			console.log(point);
		},
	},
	icons: [
		{
			title: 'Blue',
			class: 'marker-blue',
			url: '/assets/images/marker-default-blue.svg',
		},
		{
			title: 'Green',
			class: 'marker-green',
			url: '/assets/images/marker-default-green.svg',
		},
		{
			title: 'Red',
			class: 'marker-red',
			url: '/assets/images/marker-default-red.svg',
		},
	],
});
									Gets no options and returns the point set geoJSON.
$.sMap.editor.points.all();
									Gets no options and returns only the points in set that are in viewport.
$.sMap.editor.points.inView();
									Gets item index and returns the point's geometry.
$.sMap.editor.points.get(index);
									Gets item index and deletes it from the set.
$.sMap.editor.points.delete(index);
									Gets an item and adds it to the set.
$.sMap.editor.points.add(item);
									Gets an options object including a geoJSON, displays the set on the map upon start, and returns the polylines geoJSON.
| Property | Type | Default | Description | 
|---|---|---|---|
| geoJSON | geoJSON | { "type": "FeatureCollection", "features": [] } | |
| modules | Object | { cluster: false, create: false, drag: false, delete: false, get: false, editText: false, editIcon: false, } | Choose which options are enabled/disabled for the set. | 
| on | Object | { click: false, contextmenu: false, create: function(){}, drag: function(){}, delete: function(){}, get: function(){}, editText: function(){}, editIcon: function(){}, } | An object of callback functions. | 
$.sMap.editor.implement();
var polylines = {
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				title: 'Test1',
				description: 'Desc1',
			},
			"geometry": {
				"type": "LineString",
				"coordinates": [
					[51,35],
					[50,34]
				]
			}
		},
		{
			"type": "Feature",
			"properties": {
				title: 'Test2',
				description: 'Desc2',
			},
			"geometry": {
				"type": "LineString",
				"coordinates": [
					[53,32],
					[51,33]
				]
			}
		}
	]
}
polylines = $.sMap.editor.polylines.start({
	geoJson: polylines,
	modules: {
		create: true,
		edit: true,
		delete: true,
		get: true,
		editText: true,
	},
	on: {
		click: function(feature){
			console.log('click');
			console.log(feature);
		},
		contextmenu: function(feature){
			console.log('contextmenu');
			console.log(feature);
		},
		change: function(){
			console.log($.sMap.editor.polylines.all());
		},
		create: function(polyline){
			console.log('create:');
			console.log(polyline);
		},
		drag: function(polyline){
			console.log('drag:');
			console.log(polyline);
		},
		delete: function(polyline){
			console.log('delete:');
			console.log(polyline);
		},
		get: function(polyline){
			console.log('get:');
			console.log(polyline);
		},
		editText: function(point){
			console.log('editText:');
			console.log(point);
		},
		edit: function(polyline){
			console.log('editText:');
			console.log(polyline);
		},
	},
});
									Gets no options and returns the polyline set geoJSON.
$.sMap.editor.polylines.all();
									Gets item index and returns the polyline's geometry.
$.sMap.editor.polylines.get(index);
									Gets item index and deletes it from the set.
$.sMap.editor.polylines.delete(index);
									Gets an item and adds it to the set.
$.sMap.editor.polylines.add(item);
									Gets an options object including a geoJSON, displays the set on the map upon start, and returns the polygons geoJSON.
| Property | Type | Default | Description | 
|---|---|---|---|
| geoJSON | geoJSON | { "type": "FeatureCollection", "features": [] } | |
| modules | Object | { create: false, edit: false, delete: false, get: false, editText: false, } | Choose which options are enabled/disabled for the set. | 
| on | Object | { click: false, contextmenu: false, create: function(){}, edit: function(){}, delete: function(){}, get: function(){}, editText: function(){}, } | An object of callback functions. | 
$.sMap.editor.implement();
var polygons = {
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				title: 'Test1',
				description: 'Desc1',
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[55,35],
						[52,34],
						[52,36],
						[55,35]
					]
				]
			}
		},
		{
			"type": "Feature",
			"properties": {
				title: 'Test2',
				description: 'Desc2',
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[50,32],
						[57,34],
						[53,30],
						[50,32]
					]
				]
			}
		}
	]
}
polygons = $.sMap.editor.polygons.start({
	geoJson: polygons,
	modules: {
		create: true,
		edit: true,
		delete: true,
		get: true,
		editText: true,
	},
	on: {
		click: function(feature){
			console.log('click');
			console.log(feature);
		},
		contextmenu: function(feature){
			console.log('contextmenu');
			console.log(feature);
		},
		change: function(){
			console.log($.sMap.editor.polygons.all());
		},
		create: function(polygon){
			console.log('create:');
			console.log(polygon);
		},
		drag: function(polygon){
			console.log('drag:');
			console.log(polygon);
		},
		delete: function(polygon){
			console.log('delete:');
			console.log(polygon);
		},
		get: function(polygon){
			console.log('get:');
			console.log(polygon);
		},
		editText: function(point){
			console.log('editText:');
			console.log(point);
		},
		edit: function(polygon){
			console.log('editText:');
			console.log(polygon);
		},
	},
});
									Gets no options and returns the polygon set geoJSON.
$.sMap.editor.polygons.all();
									Gets item index and returns the polygon's geometry.
$.sMap.editor.polygons.get(index);
									Gets item index and deletes it from the set.
$.sMap.editor.polygons.delete(index);
									Gets an item and adds it to the set.
$.sMap.editor.polygons.add(item);
									Gets Search options and appends Search element to map view.
| Property | Type | Default | Description | 
|---|---|---|---|
| types | Object | { address: true, poi: true, } | Search Type object. | 
| counts | Object | { geocode: 5, poi: 10, } | Number of search results to be displayed either in autocomplete, or as markers in case of poi. | 
| history | Boolean | false | Whether or not a query should be added to the search history. | 
$.sMap.search.implement({
	types: {
		address: true,
		poi: true,
	},
	counts: {
		geocode: 10,
		poi: 10,
	},
	history: {
		status: true,
	},
});
									Gets Search options and resolves search programmatically.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before search. | 
| after | Function | function(){} | A task to be executed after search. | 
| query | String | empty | Search query. | 
| type | String | empty | Search Type. Available types are search and poi. | 
| icon | Object | icons.default.blue | 
$.sMap.search.look({
	query: 'restaurants',
	type: 'poi',
	icon: icons.default.blue,
});
									Gets Search Type options and sets Search Type programmatically.
| Property | Type | Default | Description | 
|---|---|---|---|
| before | Function | function(){} | A task to be executed before changing Search Type value. | 
| after | Function | function(){} | A task to be executed after changing Search Type value. | 
| value | String | empty | Search Type value. Available options are address and poi. | 
$.sMap.search.set({
	value: 'poi',
});
									Gets no options and returns current Search Type.
$.sMap.search.get();