Search code examples
javascriptmapscoordinatesamcharts

How to show circle on map in sea for the records which don't have coordinates


I have amcharts map which shows circle on it. I have few records(nearly 200) which do not have locations. These records(circle) I want to show in the map in Sea so that those records clearly will be visible.

I have tried, but circles are not working properly.

This is my code

result.forEach(element => {

if(element.loc=='NULL')
{
  element.lat=30.461829+0.102189
  element.long=152.516679+0.290019
}
});

this.mapImageSeries.data=result;

Starting lat long I have taken from here.

enter image description here

My map showing all the circle at one place. How can I showing then one around other?

enter image description here


Solution

  • Fixed this using below Javascript code

    result.forEach(element => {
    if(element.loc=='NULL')
    {     
      var r = 1000590/111300, // = 100000 meters
      y0 = 27.990741,
      x0 = 153.556045,
    
      u = Math.random(),
      v = Math.random(),
      w = r * Math.sqrt(u),
      t = 2.3 * Math.PI * v,
      x = w * Math.cos(t),
      y1 = w * Math.sin(t),
      x1 = x / Math.cos(y0),
      newY = y0 + y1,
      newX = x0 + x1
      element.lat=newY
      element.long=newX
    }
    });