Marker Plugin for Mappls Web Maps¶
Easy To Integrate Maps & Location APIs & SDKs For Web & Mobile Applications
Powered with India's most comprehensive and robust mapping functionalities. Now Available for 200+ nations and territories accross the world.
Getting Access¶
Before using the API in the your solution, please ensure that the related access is enabled in the Mappls Console, within your app - be it for Mobile OR Web or Cloud integration.
- Copy and paste the key from your
credentials
section from your API keys into theaccess_token
query parameter.- Your static key can be secured by whitelisting its usage for particular IPs (in case of cloud app usage) OR a set of domains (in case of a web app)
- Your static key obtained from your Console is to be passed as a query parameter:
access_token
.
- The sample codes are provided on our domain to help you understand the very basic functionality of Mappls Marker Plugin. See Sample Codes here
Authentication Object - access_token
mandatory query parameter.¶
access_token
: "hklmgbwzrxncdyavtsuojqpiefrbhqplnm".
Document Version History¶
Version | Last Updated | Team | Author | Remarks |
---|---|---|---|---|
1.0 | 07 Aug 2025 | SDK Product Team | Prabhjot Kaur (PK) | OAuth 2 |
Getting Access¶
Before using the Plugin in the your solution, please ensure that the related access is enabled in the Mappls Console, in the same project you set up for the Maps SDK.
- Copy and paste the generated
access token
from your API keys available in the dashboard in the sample code for interactive map development.- This APIs follow OAuth2 based security.
Access Token
can be generated using Mappls Portal
Introduction¶
A simple plugin to render places on map as markers. The Marker plugin for Mappls Web Maps JS library is provided as a means to enable rendering of searched Places via eLoc as markers top of Mappls Maps.
The plugin can be used in combination with our Interactive Map JS libraries.
The SDK offers the following basic functionalities: 1. Ability to render places directly using eLoc on Mappls Maps SDK. 2. A Mappls.elocMarker() method to initiate rendering of Places on the map specified with eLoc(s) on the map. 3. Ability to add listeners on marker events, remove markers, customize icons and get fitbounds of the markers. 4. Ability to make markers draggable and add annotations (info popups + customizable popups).
Live Demo¶
Visit the samples for assistance to create a sample implementation with your own keys.
The above implementation uses Mappls Interactive Map JS library as map rendering framework showcasing integration of marker plugin.
Implementation¶
Adding the Marker plugin script¶
Script URL¶
<script src="https://sdk.mappls.com/map/sdk/plugins?access_token=<Static Key>&v=3.0"></script>
1. Initializing the Marker plugin¶
Method¶
mappls.pinMarker()
/*marker plugin initialization*/
var markerOptions={
map:map,
pin:[‘mmi000’,’123zrr’],
popupHtml:[“<h1>MMI</h1>”,”<h1>Agra</h1>”],
html:[“1”,”2”],
icon:{url:’2.png’,width:30,height:45}
}
mappls.pinMarker(markerOptions,callback);
OR
mappls.pinMarker({map:map,pin:'mmi000',popupHtml="<h1>MMI</h1>"});
Mandatory Parameters¶
map
: object > vector map or raster map object from respective Mappls Map JS.pin
: array of strings containing the eLoc(s) which need to be showcased on the map. e.g.
[‘mmi000’,’123zrrr’]
Optional Parameters¶
html
: (string or html) Text which needs to be written over the marker or if there is a need for further customization, then this param can also take in HTML div. e.g.
'mappls'
OR
[“<b>MMI</b>”,”<b>AGRA</b>”]
popupHtml
: (string or HTML) What needs to be displayed when marker is clicked. e.g.
[“<h1>Mappls</h1>”,”<p>Agra</p>”]
popupOptions
: (object) if the popup/annotation needs to be customized further. The following are the sub-params for the object:className
: the class name of the annotation object.offset
: the offset positioning from the marker.openPopup
: (boolean) indicating if the pop needs to be open on addition of marker or not as default. e.g.
{
className:'myClass',
offset:{},
openPopup:true //open popup as default with add marker
}
-
icon
: (object) the customized marker icon options. The following are the sub-params for the object:url
: the URL specifying the marker image.width
: width of the marker icon.height
: height of the marker icon.offset
: offset positioning of the marker's anchor.popupAnchor
: positioning of the marker popup's anchor.
e.g.
{
url:'https://apis.mappls.com/map_v3/2.png',
width:30,
height:40,
offset:[20,40],
popupAnchor:[-5,-40]
}
draggable
: (boolean) to set the marker(s) as draggable or not.
2. Method for getting all markers to fit in a viewbound¶
Method¶
fitbounds()
obj.fitbounds(options); //options are optional e.g. {padding:100}
padding
: option can be used to setup a padding around the viewbound to fit the markers in.
3. Method for removing markers with callback¶
Method¶
remove()
obj.remove();
4. Method for adding event listeners on the marker¶
Method¶
addListener()
obj.addListener(event,callback);
Example:
obj.addListener(‘click’,function(data){console.log(data);});
5. Method for removing event listeners on the marker¶
Method¶
removeListener()
obj.removeListener(event);
Example:
obj.removeListener(‘click’);
6. Method for setting icons for markers¶
Method¶
setIcon()
obj.setIcon(‘url.png’); //replaces all marker's icon.
OR
obj.setIcon(‘url.png’,’mmi000’); //replaces single marker's icon for the provided eLoc.
7. Method for setting pophtml for markers¶
Method¶
setPopup()
obj.setPopup({content:"<h1>Mappls</h1>"}); //replaces all marker's pop up values.
OR
obj.setPopup({content:"<h1>Agra</h1>",pin:'123zrr'}); //replaces single marker's popup value for the provided Pin.
That's All ! Visit the samples for assistance to create a sample implementation with your own keys.
For any queries and support, please contact:
Email us at apisupport@mappls.com
Support
Need support? contact us!