0

So currently I'm using react-simple-map to make a map that with marker. It required this json format:

[{
   "coordinates":{
      "0":139.6917,
      "1":35.6480
   },
      "name":"Tokyo",
  },
  {
    "coordinates":{
      "0":101.9758,
      "1":4.2105
    },
    "name":"Malaysia",
}]

Then I'm trying to change the label in .net like this:

 public IQueryable<Object> GetCoordination()
        {
            return from a in _awContext.SalesTerritories
                   join p in _awContext.Coordination
                   on a.TerritoryId equals p.TerritoryID
                   select new
                   {
                       id = a.TerritoryId,
                       coordinates = new 
                       {
                           '0' = p.Lat,
                           '1' = p.Long,    
                       },
                       name = a.Name,
                       countryRegionCode = a.CountryRegionCode,
                       salesYtd = a.SalesYtd,
                       salesLastYear = a.SalesLastYear,
                       costYtd = a.CostYtd,
                       costLastYear = a.CostLastYear,

                   };
        }

What happen is the 0 & 1 have error.

Is there anyway to make it integer.

tedeeee
  • 47
  • 5

1 Answers1

0

you should not have array key

{
    "coordinates": [0.1234,1.2345]
}

Cheers !

Djb
  • 109
  • 8