如何在c#中包含地图 [英] How to include map in c#

查看:94
本文介绍了如何在c#中包含地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在我的网站上使用谷歌地图。



我有4个位置,我想在点击相应位置的链接按钮时去每个位置。



以下是我使用的代码



Hi,
I want to use google map in my website.

I have 4 locations and I want to go to each location when link button for corresponding location is clicked.

Here is the code I am using

<script type="text/javascript">
    function init_map() {
        var myOptions = {
            zoom: 6, center: new google.maps.LatLng(40.805478, -73.96522499999998), mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
        marker = new google.maps.Marker({ map: map, position: new google.maps.LatLng(40.805478, -73.96522499999998) });
        infowindow = new google.maps.InfoWindow({ content: "india<br/>2880 Broadway<br/> New York" });
        google.maps.event.addListener(marker, "click", function () { infowindow.open(map, marker); });
        infowindow.open(map, marker);
    }
    google.maps.event.addDomListener(window, 'load', init_map);

    function Goto(lat, long) {
        debugger;
        var myOptions = {
            zoom: 6, center: new google.maps.LatLng(lat, long), mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
        marker = new google.maps.Marker({ map: map, position: new google.maps.LatLng(40.805478, -73.96522499999998) });
        infowindow = new google.maps.InfoWindow({ content: "<br/>2880 Broadway<br/> New York" });
        google.maps.event.addListener(marker, "click", function () { infowindow.open(map, marker); });
        infowindow.open(map, marker);
    }

</script>

body>
        <form runat="server">
            <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="Goto(33.7018259,-117.85699)">1231 East Dyer Road</asp:LinkButton>
            <asp:LinkButton ID="LinkButton2" runat="server" OnClientClick="Goto(40.764847,-73.9782006)">123 West 57th Street</asp:LinkButton>
            <asp:LinkButton ID="LinkButton3" runat="server" OnClientClick="Goto(22.3009512,114.172173)">Unit 1603, 16/F Miramar Tower</asp:LinkButton>
            <asp:LinkButton ID="LinkButton4" runat="server" OnClientClick="Goto(48.8567,2.3508)">36-38 rue des Mathurins</asp:LinkButton>
        </form>
    </body>





我得到的是每当我点击链接按钮时它都没有导航到该位置。你能帮我吗??





谢谢,

提前



What I am getting is whenever I click the link button it is not navigating to the location. Can you please help me.?


Thanks,
In advance

推荐答案

除非你需要链接进行回发,否则不要使用LinkBut​​ton,而是使用普通链接



Don't use LinkButton unless you need the link to do a postback, use a normal link instead

<a href="#" onclick="Goto(33.7018259,-117.85699); return false;">1231 East Dyer Road</a>


这篇关于如何在c#中包含地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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