Click here to Skip to main content
15,886,037 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi
I am able to text file in asp.net the text file have latitude and longitude
using
<script runat="server">
    Sub WriteToFile(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Put user code to initialize the page here
        'Dim fp As StreamReader
         'Dim mystr As String
         Dim mypoints() As String
         
         Try
             Dim readFile As System.IO.TextReader = New  _
     StreamReader("C:\vnr.txt")
             Dim mystr = readFile.ReadToEnd()
             mypoints = mystr.Split(";\n").ToArray
             readFile.Close()
         Catch err As Exception
             lblStatus.Text = "File Read failed. Reason is as follows <br><br>" & err.ToString()
         Finally

         End Try
    End Sub
</script>




from above code i want to read mypoints array to pts instead of assigning those values

C#
<script type="text/javascript">

   //<![CDATA[


   if (GBrowserIsCompatible()) {


     // Display the map, with some controls and set the initial location

     var map = new GMap(document.getElementById("map"));

     map.addControl(new GLargeMapControl());

     map.addControl(new GMapTypeControl());

     map.setCenter(new GLatLng(17.541536925025802,78.38722586631775),15);


     // create a polygon
   
    // var pts = [new GLatLng(17.541536925025802,78.38722586631775), new GLatLng(17.541148187221358,78.3871078491211),

               // new GLatLng(17.540636688840067,78.38702201843262), new GLatLng(17.540145649036166,78.38693618774414),

               // new GLatLng(17.53968529801197,78.38677525520325),new GLatLng(17.53921471575673,78.38651776313782),

               // new GLatLng(17.53835538848651,78.38580965995789),new GLatLng(17.53732214435186,78.38572382926941),

             //  new GLatLng(17.536104750142222,78.38491916656494),new GLatLng(17.53733237452067,78.38338494300842),

               // new GLatLng(17.539265866061044,78.38428616523743),new GLatLng(17.54188474235469,78.38574528694153),

                 //new GLatLng(17.541536925025802,78.38722586631775)];

     var polygon = new GPolygon(pts, null, 5, 0.7, "#aaaaff", 0.5, {clickable:false} );

     map.addOverlay(polygon);

      // === A method for testing if a point is inside a polygon

     // === Returns true if poly contains point

     // === Algorithm shamelessly stolen from http://alienryderflex.com/polygon/

     GPolygon.prototype.Contains = function(point) {

       var j=0;

       var oddNodes = false;

       var x = point.lng();

       var y = point.lat();

       for (var i=0; i < this.getVertexCount(); i++) {

         j++;

         if (j == this.getVertexCount()) {j = 0;}

         if (((this.getVertex(i).lat() < y) && (this.getVertex(j).lat() >= y))

         || ((this.getVertex(j).lat() < y) && (this.getVertex(i).lat() >= y))) {

           if ( this.getVertex(i).lng() + (y - this.getVertex(i).lat())

           /  (this.getVertex(j).lat()-this.getVertex(i).lat())

           *  (this.getVertex(j).lng() - this.getVertex(i).lng())<x ) {

             oddNodes = !oddNodes

           }

         }

       }

       return oddNodes;

     }


if any one know this please help me

Thanks and Regards
N.L.Kalyani

[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 30-Jun-11 22:50pm
v2

1 solution

Your values are on the server and need to be passed to the client. Creating something like :

// var pts = [new GLatLng(17.541536925025802,78.38722586631775), new GLatLng(17.541148187221358,78.3871078491211),
// new GLatLng(17.540636688840067,78.38702201843262), new GLatLng(17.540145649036166,78.38693618774414),
// new GLatLng(17.53968529801197,78.38677525520325),new GLatLng(17.53921471575673,78.38651776313782),
// new GLatLng(17.53835538848651,78.38580965995789),new GLatLng(17.53732214435186,78.38572382926941),
// new GLatLng(17.536104750142222,78.38491916656494),new GLatLng(17.53733237452067,78.38338494300842),
// new GLatLng(17.539265866061044,78.38428616523743),new GLatLng(17.54188474235469,78.38574528694153),
//new GLatLng(17.541536925025802,78.38722586631775)];

which is in your code, but commented out, is the only real option, unless the values change and you want to get them with AJAX calls, which will still pass the same sort of thing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900