Storing Geometry Point(s) on Javascript

We’re going to create a map swipe. You’ll be able to compare two maps with a bar to slide between the two layers. We’ll use Sentinel 2 Global layer and base Stament layer as an example. This guide takes a deeper dive into JavaScript with Ramani.js to build an interactive web map. If you’re new to Ramani.js you might want to check out this page first.

Turn your engine on

For this project, we recommend that you create a local folder called "map-swipe" to house your project files. We’ll refer to this folder as your project folder.

You need prepare some item before can start this project :

  • A map ID. An ID points to a unique map you have created on Ramani Cloud. Check this page and learn how to make it
  • Your API token. The token is used to associate a map with your account:
    var rc = new RamaniAPI(); rc.init({ username:'
    username', apiKey:'
    API_KEY', package:'
    package' });
  • Ramani.js. The Ramani JavaScript API for building maps.
  • A text editor. You’ll be writing HTML, CSS, and JavaScript after all.

Preparing the page

In your project folder, create an index.html file. Set up the document by adding jQuery, LeafletJs, Ramani.js and CSS at the head section.

  <link rel="stylesheet" href="" />

  <script src=""></script>

Next, let’s markup the page to create a map container and sidebar listing on the body section.

  <div style="width: 800px;height: 500px;" id="map"></div>
  <input id='range' class='range' type='range' min='0' max='1.0' step='any' />

Let’s also apply some CSS so we can visualize what the layout looks like.

  #map { position:absolute; top:0; bottom:0; width:100%; }
  .range {

Initializing the map

We’ll now initialize the map in the JavaScript code exactly like we did in the quick start guide, but won’t set the map view yet:

var rc = new RamaniAPI();
var map ={
    center : new L.LatLng(41.3768, 2.3291),
    zoom : 10,
    baselayer : 'osm'

var drawnItems = new L.FeatureGroup();
var drawControl = new L.Control.Draw({
edit: {
    featureGroup: drawnItems

Draw Geometry and Store

We now ready to make map swipe functionality :

map.on('draw:created', function (e) {
    var type = e.layerType,
        overlay = e.layer;
    var bbox; 
        if (type != 'circle' && type != 'marker' && type != 'polyline') {
          //store polygon 
          var langs = overlay.getLatLngs(); 
            var fields = {
              id : '1',    
              name : 'asdasd'
              var storePolygon = rc.storePolygon('public.store_polygon',fields, langs );
        }else if (type == 'polyline'){
            //store line
            var langs = overlay.getLatLngs(); 
            var fields = {
              id : '1',    
              name : 'asdasd'
            var storeLine = rc.storeLine('public.store_polyline',fields, langs );
        }else if (type === 'marker'){
          //store point
          var fields = {
              id : '1',    
              name : 'asdasd'
          rc.storePoint('public.store_point', fields, overlay.getLatLng());

Mission complete

That's it, you project ready to publish and if your success your view will like this example