使用Reimer ASP.NET控件的Google Maps V3 [英] Google Maps V3 Using Reimer ASP.NET Control

查看:66
本文介绍了使用Reimer ASP.NET控件的Google Maps V3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用reimers.dk的ASP.NET控件,并且能够查看地图,添加缩放/平移控件.在地图内平移和缩放都可以正常工作.我的问题是使地图以ASP.NET发送的点为中心,例如单击按钮即可.地图没有任何影响或改变.感谢您提供任何帮助.

I'm using the ASP.NET control from reimers.dk and I was able to view the map, add zoom/pan controls. Panning and zooming work fine from within the map. My problem is getting the map to center on a point sent from ASP.NET, like from a button click. There is no effect or change to the map. Any help with this is appreciated.

以下是页面和代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>


<%@ Register assembly="Reimers.Google.Map" namespace="Reimers.Google.Map" tagprefix="Reimers" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>


                        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"  Text="Button" />


                <Reimers:Map ID="Map1" runat="server" Width="600" Height="400" DefaultMapType="Terrain">
    <Center Latitude="51.477" Longitude="0.0" />

</Reimers:Map>     

      </ContentTemplate>
                </asp:UpdatePanel>

    </form>
</body>
</html>

//////////////////////////////////////

//////////////////////////////////////

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Map1.MapControls.Add(new Reimers.Google.Map.Controls.ZoomControl());
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Map1.SetCenter(new Reimers.Google.Map.LatLng(27, -82));

    }
}

我也尝试了没有此控件的js.我得到了类似的结果.

I also tried with js, without this control. I got similar results..

先谢谢您.

推荐答案

我花了一些时间才弄清楚这一点.这段代码对我来说可以在Page_Load方法中设置中心:

It took me some time to figure this out. This code works for me to set the center in the Page_Load method:

LatLng laln = new LatLng();
laln.Latitude = 65;
laln.Longitude = -19;
Map1.Center = laln;

这篇关于使用Reimer ASP.NET控件的Google Maps V3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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