谷歌地图/ iframe动态src元素

时间:2012-07-13 16:57:31

标签: asp.net vb.net iframe src google-maps-api-2

好吧所以我的问题是我有一个用于显示googlemaps的iframe

iframe的src将设置为点击googlemaps,其中从数据库中读取的地址作为位置插入

当时帧只是纯白色,甚至没有图片出现,但是如果将src路径放入浏览器URL中它工作正常,我的测试网址是 “http://maps.google.com/maps/api/staticmap?markers=27+Landseer+Street,+Belfast&size=500x300&sensor=false”

这是有效的,因为你会看到你是否放入地址栏。

我的目标是让三个框架全部单独命名,然后在它们上面设置src。 这是我到目前为止的代码

VB.NET     公共课关于     继承System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Session("recentAddressmap1") = ""
    Session("recentAddressmap2") = ""
    Session("recentAddressmap3") = ""
    Session("src1") = ""
    Session("src2") = ""
    Session("src3") = ""
    Dim recentCount As Integer
    recentCount = 0
    Dim addresstest As String = "27 Landseer Street"
    Dim words As String() = addresstest.Split(New Char() {" "c})

    ' Use For Each loop over words and display them
    Dim word As String
    Dim newaddress As String = ""
    Dim loopcounter As Integer = 0
    For Each word In words
        If loopcounter = 0 Then
            newaddress = word
            loopcounter = loopcounter + 1
        Else
            newaddress = newaddress & "+" & word
        End If
    Next
    '''''''''''''''''''''''''''''''''''''''''' DO ENTRY RECENT 1 '''''''''''''''''''''''''''''''''''''''''''''''''''
    Session("recentAddressmap1") = newaddress & ",Belfast"
    Session("src1") = "http://maps.google.com/maps/api/staticmap?markers=" & Session("recentAddressmap1") & "&size=500x300&sensor=false"
    'MsgBox(Session("src1"))
    visualAddress1.Attributes.Add("src", Session("src1"))
End Sub

结束班

ASPX

<%@ Page Title="About Us" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="About.aspx.vb" Inherits="email_tester.About" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
               <iframe width="425" height="350" scrolling="no" marginheight="0" marginwidth="0" id="visualAddress1" runat="server"></iframe>

</asp:Content>

1 个答案:

答案 0 :(得分:0)

如何给iframe提供一个ID + runat = server,然后从VB设置src?