从vb读取数组值到脚本 [英] Reading array values from vb to script

查看:74
本文介绍了从vb读取数组值到脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我可以在asp.net中输入文本文件,该文本文件具有经度和纬度
使用

<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>





从上面的代码中,我想将mypoints数组读取为pts而不是分配这些值

 < script    类型  ="  >> 

   // <![CDATA [


   如果(GBrowserIsCompatible()){


     // 显示地图,并带有一些控件并设置初始位置

      var  map =  GMap(document.getElementById(" 地图"));

     map.addControl( GLargeMapControl());

     map.addControl( GMapTypeControl());

     map.setCenter( GLatLng( 17 . 541536925025802  78 . 38722586631775 ), 15 );


     // 创建多边形
   
    //  var pts = [new GLatLng(17.541536925025802,78.38722586631775),new GLatLng(17.541148187221358,78.3871078491211),

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

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

               // 新GLatLng(17.53835538​​848651,78.38580965995789),新GLatLng(17.53732214435186,78.38572382926941),

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

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

                 // 新GLatLng(17.541536925025802,78.38722586631775)]; 

      var 多边形=  GPolygon(pts, 5  0 . 7 "  0 . 5 ,{clickable: false });

     map.addOverlay(polygon);

      //  ===一种测试点是否在多边形内的方法

     //  ===如果多边形包含点,则返回true 

     //  ===从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 <   .getVertexCount(); i ++){

         j ++;

         如果(j ==  this  .getVertexCount()){j = 如果((((( this  .getVertex(i).lat() .getVertex(j).lat()> ;  = y))

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

           如果( .getVertex(i).lng()+(y- .getVertex(j).lat()-this.getVertex(i).lat())

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

             奇数节点=!oddNodes

           }

         }

       }

       返回奇节点;

     } 



如果有人知道这一点,请帮助我

谢谢与问候
卡利亚尼(N.L. Kalyani)

[edit]已添加代码块,忽略HTML ..."选项已禁用-OriginalGriff [/edit]

解决方案

您的值在服务器上,需要传递给客户.创建类似的内容:

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

除非您更改值并且您想通过AJAX调用获取它们,否则代码中的代码(但已注释掉)是唯一的实际选择.


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

<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]

解决方案

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.


这篇关于从vb读取数组值到脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆