如何在 ASP.Net 网站中集成雅虎地图

发布于 2024-09-25 23:56:42 字数 458 浏览 1 评论 0原文

如果我们将地址作为查询字符串传递,如何在 gridview 中显示雅虎静态地图?另请告诉如何显示动态雅虎地图。我搜索了雅虎地图并获得了以下链接 http://developer.yahoo.com/ flash/maps/examples.html, http://developer.yahoo.com/地图/rest/V1/http://developer.yahoo.com/maps/。我没有收到任何包含在 ASP.Net 网站中集成 yahoo 地图的代码的链接!

How to display yahoo static map in gridview if we pass address as query string? Also please tell how to display dynamic yahoo maps also. I have searched about yahoo maps and got the following links http://developer.yahoo.com/flash/maps/examples.html, http://developer.yahoo.com/maps/rest/V1/ and http://developer.yahoo.com/maps/. I did not get any link which has code for integrating yahoo map in an ASP.Net website!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把梦留给海 2024-10-02 23:56:42

我创建了雅虎动态地图,地址可以作为页面中存在的隐藏字段的值传递。隐藏字段的值可以在 page_load 事件中动态传递。我在 ASP.Net 中母版页封装的子页面中创建了这个。

在开始之前,用户必须通过登录您的 yahoo ID 并导航到此链接 https://login.yahoo.com/config/login_verify2?.src=devnet&.done=http://developer .apps.yahoo.com/wsregapp/ 并提供我们的网站 URL。

显示雅虎地图的代码如下:

。地图 {
高度:400像素;
宽度:700 像素;
字体系列:Verdana;
字体大小:11px;
字体粗细:粗体;
}

<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=YourAPPID">  
</script>

<script type="text/javascript">

    // Capture the user mouse-click and expand the SmartWindow
    function onSmartWinEvent() {


        // Create a map object
        var map = new YMap(document.getElementById('<%= map.ClientID %>'));
        // Add a pan control
        map.addPanControl();
        // Add a slider zoom control
        map.addZoomLong();
        // Display the map centered on the address specified          
        map.drawZoomAndCenter(document.getElementById('<%= HiddenField1.ClientID %>').value, 3);
        // Create a marker positioned at the address specified
        var marker = new YMarker(document.getElementById('<%= HiddenField1.ClientID %>').value, createCustomMarkerImage());
        // Add a label to the marker
        //marker.addLabel("<blink>*</blink>");
        // Call onSmartWinEvent when the user clicks on the marker 
        YEvent.Capture(marker, EventsList.MouseClick, onSmartWinEvent);
        // Display the marker 
        map.addOverlay(marker);


        var words = document.getElementById('<%= HiddenField1.ClientID %>').value;
        marker.openSmartWindow(words);

        // Add map type control   
        map.addTypeControl();
        // Default map to satellite (YAHOO_MAP_REG) -- other opts: YAHOO_MAP_HYB,YAHOO_MAP_SAT
        map.setMapType(YAHOO_MAP_REG);
    }

    function createCustomMarkerImage() {
        var myImage = new YImage();
        myImage.src = 'http://l.yimg.com/www.flickr.com/images/dot_splat.png';
        myImage.size = new YSize(30, 31);
        myImage.offsetSmartWindow = new YCoordPoint(15, 15);
        return myImage;
    }
</script>

<table width="100%" align="left">        
    <tr>
        <td>
            <body onload="onSmartWinEvent()">
                <div id="map" class="map" runat="server">
                </div>
                <asp:HiddenField ID="HiddenField1" runat="server" />
            </body>
        </td>
    </tr>
</table>

注意:速率限制:Yahoo! AJAX Maps API 限制为每个 IP 每天 50,000 次查询。检查此链接
http://developer.yahoo.com/search/rate.html

I have created yahoo dynamic map, the address can be passed as value of a hidden field present in the page. The value for hidden field can be dynamically passed in page_load event. I have created this in the child page encapsulated by master page in ASP.Net.

Before starting, the user has to generate Application ID for using yahoo maps by logging into your yahoo ID and navigating to this link https://login.yahoo.com/config/login_verify2?.src=devnet&.done=http://developer.apps.yahoo.com/wsregapp/ and providing our website URL.

The code for displaying yahoo map is given below:

.map {
height: 400px;
width: 700px;
font-family:Verdana;
font-size:11px;
font-weight:bold;
}

<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=YourAPPID">  
</script>

<script type="text/javascript">

    // Capture the user mouse-click and expand the SmartWindow
    function onSmartWinEvent() {


        // Create a map object
        var map = new YMap(document.getElementById('<%= map.ClientID %>'));
        // Add a pan control
        map.addPanControl();
        // Add a slider zoom control
        map.addZoomLong();
        // Display the map centered on the address specified          
        map.drawZoomAndCenter(document.getElementById('<%= HiddenField1.ClientID %>').value, 3);
        // Create a marker positioned at the address specified
        var marker = new YMarker(document.getElementById('<%= HiddenField1.ClientID %>').value, createCustomMarkerImage());
        // Add a label to the marker
        //marker.addLabel("<blink>*</blink>");
        // Call onSmartWinEvent when the user clicks on the marker 
        YEvent.Capture(marker, EventsList.MouseClick, onSmartWinEvent);
        // Display the marker 
        map.addOverlay(marker);


        var words = document.getElementById('<%= HiddenField1.ClientID %>').value;
        marker.openSmartWindow(words);

        // Add map type control   
        map.addTypeControl();
        // Default map to satellite (YAHOO_MAP_REG) -- other opts: YAHOO_MAP_HYB,YAHOO_MAP_SAT
        map.setMapType(YAHOO_MAP_REG);
    }

    function createCustomMarkerImage() {
        var myImage = new YImage();
        myImage.src = 'http://l.yimg.com/www.flickr.com/images/dot_splat.png';
        myImage.size = new YSize(30, 31);
        myImage.offsetSmartWindow = new YCoordPoint(15, 15);
        return myImage;
    }
</script>

<table width="100%" align="left">        
    <tr>
        <td>
            <body onload="onSmartWinEvent()">
                <div id="map" class="map" runat="server">
                </div>
                <asp:HiddenField ID="HiddenField1" runat="server" />
            </body>
        </td>
    </tr>
</table>

NOTE: Rate limiting: The Yahoo! AJAX Maps API is limited to 50,000 queries per IP per day. Check this link
http://developer.yahoo.com/search/rate.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文