我正在使用此功能使用虚拟地图显示地图。当我运行这个时,我得到<% if (b == 0) Then %>
期待的表达式的异常,我做错了什么
以下是我的javascript代码
我宣布Dim b As Integer
<script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&s=1&mkt=en-us"></script>
<script type="text/javascript">
var myMap = null;
function LoadMap()
{
myMap = new VEMap("mapDiv");
myMap.LoadMap();
myMap.SetZoomLevel(1);
<% If RS.HasRows Then %>
<% if (b == 0) Then %>
StartGeocoding<%=b %>("<%= rs("lot_address") & " " & rs ("lot_city") %>, <%= rs("lot_state") & " " & rs("lot_zip")%>");
<% end if%>
function StartGeocoding<%=b%> ( address )
{
myMap.Find(null, // what
address, // where
null, // VEFindType (always VEFindType.Businesses)
null, // VEShapeLayer (base by default)
null, // start index for results (0 by default)
null, // max number of results (default is 10)
null, // show results? (default is true)
null, // create pushpin for what results? (ignored since what is null)
null, // use default disambiguation? (default is true)
<%if(b==0) Then %>
null, // set best map view? (default is true)
<%else%>
false, // set best map view? (default is true)
<%end if%>
GeocodeCallback<%= b %>); // call back function
}
function GeocodeCallback<% =b %> (shapeLayer, findResults, places, moreResults, errorMsg)
{
// if there are no results, display any error message and return
if(places == null)
{
alert( (errorMsg == null) ? "There were no results" : errorMsg );
return;
}
var bestPlace = places[0];
// Add pushpin to the *best* place
var location = bestPlace.LatLong;
var newShape = new VEShape(VEShapeType.Pushpin, location);
var desc = "<%=rs("lot_address")%><br /><%=rs("lot_city")%>, <%=rs("lot_state")&" "&rs("lot_zip")%><br /><br /><a href='lot.asp?id=<%=rs("id")%>' class='link' style='color:black;'><strong>» Get More Details & Rates</strong></a>";
newShape.SetDescription(desc);
newShape.SetTitle("<%=rs("lot_name")%>");
myMap.HideInfoBox();
myMap.AddShape(newShape);
myMap.HideInfoBox();
<%rs.movenext
if RS.HasRows Then
if (b==1) then%>
myMap.ZoomOut();
<%end if%>
StartGeocoding<%=b+1%>("<%=rs("lot_address")&" "&rs("lot_city")%>, <%=rs("lot_state")&" "&rs("lot_zip")%>");
<%else
%>
myMap.ZoomOut();
<%end if
// rs.moveprevious :
%>
myMap.HideInfoBox();
}
<%
b=b+1
rs.read
loop
rs.
%>
myMap.HideInfoBox();
}
function UnloadMap()
{
if (myMap != null) {
myMap.Dispose();
}
}
</script>
答案 0 :(得分:1)
您需要更改此行(加上以类似语法编写的其他行):
<% if (b==0) Then %>
到此:
<% If b = 0 Then %>
好像你在同一个代码块中混合了VB.NET语法和javascript。 <{1}}中的那个部分应该只用VB.NET编写,只需要更加小心。