谷歌地图/Iframe 动态 src 元素

Google maps / Iframe dynamic src element

提问人:PKYNI 提问时间:7/14/2012 更新时间:7/14/2012 访问量:1303

问:

好的,所以我的问题是我有一个旨在显示谷歌地图的 iframe

iframe 的 src 将被设置为命中 googlemaps,并从数据库中读取的地址作为位置插入

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

这是有效的,因为如果您放入地址栏,您将看到。

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

VB.NET Public Class 关于 继承 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

End 类

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>
asp.net vb.net iframe src google-maps-api-2

评论


答:

0赞 Fabio 7/14/2012 #1

给 iframe 一个 ID + runat=server,然后从 VB 设置 src 怎么样?