【问题标题】:How to integrate Yahoo map in ASP.Net website如何在 ASP.Net 网站中集成 Yahoo 地图
【发布时间】:2010-10-04 11:46:38
【问题描述】:

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

【问题讨论】:

    标签: asp.net maps yahoo-maps


    【解决方案1】:

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

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

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

    。地图 { 高度:400px; 宽度:700px; 字体系列: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 地图 API 限制为每个 IP 每天 50,000 次查询。检查此链接 http://developer.yahoo.com/search/rate.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      • 2012-10-22
      • 2011-06-18
      • 1970-01-01
      • 2012-05-28
      • 2013-07-18
      • 1970-01-01
      相关资源
      最近更新 更多