我有一些服务器端vb.net代码从DB获取数据。服务器端代码是
Dim mgps As New Text.StringBuilder
Public ReadOnly Property GPS() As String
Get
Return mgps.ToString
End Get
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As New OleDbConnection
con = New OleDbConnection("Data Source=sml; User ID=sml; Password=sml; provider=OraOLEDB.Oracle")
con.Open()
Dim cmd As OleDbCommand = New OleDbCommand("Select STA_NAME, GPS_ONE from GPS", con)
Dim ds As New DataSet
Dim I As Long
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, "GPS")
For I = 0 To ds.Tables("GPS").Rows.Count - 1
mgps.AppendLine(ds.Tables("GPS").Rows(I).Item("GPS_ONE"))
Next I
End Sub
这里是客户端JS代码,我想使用服务器端循环数据
var GPS1 = '<%=GPS %>';
var GPS = new Array();
GPS = [
new google.maps.LatLng(GPS1)
];
for(i=0; i<GPS.length; i++)
{
var image = 'ico/no.png';
var infowindow = new google.maps.InfoWindow();
var ContentString = 'SML';
markers[i] = new google.maps.Marker(
{
position: GPS[i],
map: map,
draggable:true,
icon:image,
title: "Adeel" + (i+1)
});
但是通过这段代码我的地图没有加载。请告诉我如何将服务器端循环值用于JS数组以将LatLang分配给标记