Retrieve Polygon on a Google Map with datatype geography

Retrieve Polygon on a Google Map with datatype geography

To retrieve a polygon (that has a list of lat, long coordinates) on a google map with a data type of geography.

The function below (C#) extract a polygon, by first converting to a string and then doing a regex to filter data that is not needed. The formatted that is return is a string, it is not a formatted json.

 int res = (int)type1.InvokeMember("AddNumb", BindingFlags.InvokeMethod,null,
                                  obj, mParam);
//Here is the complete code:
using System;
using System.Reflection;

namespace Reflection
{
   class Class1
   {
    public int AddNumb(int numb1, int numb2)
    {
      int ans = numb1 + numb2;
      return ans;
    }

  [STAThread]
  static void Main(string[] args)
  {
     Type type1 = typeof(Class1); 
     //Create an instance of the type
     object obj = Activator.CreateInstance(type1);
     object[] mParam = new object[] {5, 10};
     //invoke AddMethod, passing in two parameters
     int res = (int)type1.InvokeMember("AddNumb", BindingFlags.InvokeMethod,
                                        null, obj, mParam);
     Console.Write("Result: {0} \n", res);
   }
  }
}

 

On the frontend, since this string is not a proper json format, you can use eval function in javascript to translate the string to object class. In terms of performance, eval function is said to bit slow.

 

Leave a Reply

Your email address will not be published. Required fields are marked *