Developers Knowledge Base

Mobile and field solutions function as an extension of the overall enterprise, and include the ability to access, create, review and update geospatial data and asset information in real-time in the field.
Showing results for 
Search instead for 
Do you mean 

Application API

by Technical Evangelist ‎08-12-2015 06:28 AM - edited ‎02-08-2017 01:26 AM (3,083 Views)

Keep making simple things simple and complex things possible with gsp API!


Getting the API

There are no prerequisites to use API. It is already included as the integral part of Mobile MapWorks Essentials and Advantage application.


API Documentation


API Examples


Using the API

To start adding your custom code right into the customized application edit the custom.js file. Replace the commented lines with your customizations. The custom.js file is already provided in the default Mobile MapWorks Essentials and Advantage application. It acts as a placeholder for injecting custom code.


Content of custom.js file:


 gsp.ready("v1.0", function(gsp) {
     // put your code here


gsp.ready function abstracts the process of loading the page and scripts necessary for MapWorks Essentials and Advantage to operate and, as its pretty descriptive name announces, executes your code when gsp is ready. For example:


 <script type="text/javascript">
 gsp.ready(function () {
     // your code that interacts with the app
     // it will be executed when the whole application is loaded,
     // DOM is ready and all necessary scripts have been initialized.


There is no problem to define functions outside of that block and then just make sure that they are executed inside of it. Think of it as a main entry point of your application (although you can use it many times - each of the registered callback will be executed, but with no specified order).


Custom HTML

If you choose to create separate html file add new <script> tag in your html, either pointing to a separate javascript file aimed for your customizations (as we all love order!):


<script type="text/javascript" src="myCustomScript.js"></script>


or just a simple inline block for playing around:


 <script type="text/javascript">
 gsp.ready("v1.0", function(gsp) {
      // Center map in 0, 0 point{ x: 0, y: 0 });


Ensure that app.js script file is included:


<script type="text/javascript" src="app.js"></script>


Ensure that app.css stylesheet file is included:


<link rel="stylesheet" href="style/app.css" />


Ensure that cordova.js script file is included:


<script type="text/javascript" src="cordova.js"></script>


It is required to follow the html tags constraints, make sure to copy <body> from original html (as provided in index.html).


Custom CSS

Some of the controls use predefined CSS classes that allow customization of their appearance.

You can create your own CSS file and include it in Mobile MapWorks Essentials and Advantage applications. It will act as placeholder for injecting custom stylesheet.


<link rel="stylesheet" href="style/examples.css" />



API is written in functional style JavaScript and most of the flow control happens in callbacks.

Most of the functions are written in the way:


 function foo (config, callback, errback) {

where config object simulates named parameters (so instead of passing 5 formal parameters we pass 1 but with a dictionary of properties), callback is function that is executed when the foo operation succeeds (so we can treat it as a kind of return statement from the synchronous world) and errback is executed when the foo operation fails. Some methods do not have the errback parameter and there the assumption is that callback is executed all the time (this is for simplification where there is rather no possibility of "failing").



API covers:

  • map manipulation (zooming, panning...)
  • legend manipulation (adding, removing layers)
  • registering map and search services
  • pin layer
  • coordinate systems
  • name search
  • basic user interface manipulation
  • other Application API features not mentioned here

    Enjoy using the Application API!