TransWikia.com

How to add points (marker) in Mapbox real time geolocation with Cassandra database?

Geographic Information Systems Asked by Dhia Hannachi on May 24, 2021

I am now using Angular in web and ionic in mobile with spring-boot for communicate between web and mobile and I use Cassandra for database.

I get longitude and latitude of mobile geolocation in real time, but I want put the points that I got in real time on the Mapbox in order to see the movements of the phone in my web page.

  var url = 'http://localhost:8081/api';
  map.on('load', function() {


    var iv=0;

    var request = new XMLHttpRequest();
    window.setInterval(function() {

   
    request.open('GET', url, true);
    request.onload = function() {
    if (this.status >= 200 && this.status < 400) {
    // retrieve the JSON from the response
    var json = JSON.parse(this.response);
    console.log(json);
    //// update the drone symbol's location on the map




  if(iv<json.length)
    {
      console.log(iv);

     var marker=new mapboxgl.Marker({color: 'red'});
     marker.setLngLat([json[iv].longitude_x, json[iv].laltitude_y])
     .setPopup(new mapboxgl.Popup().setHTML("<h1>"+json[iv].name+"</h1>")).addTo(map);
    }


  iv++;


 } 

When i write this code the markers if seting this markers over some in map !

I want help, please !

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP