Pergunta

Como exibir o mapa estático do Yahoo em Gridview se passarmos o endereço como string de consulta? Também diga como exibir mapas dinâmicos do Yahoo também. Eu procurei sobre mapas do Yahoo e recebi os seguintes links http://developer.yahoo.com/flash/maps/examples.html, http://developer.yahoo.com/maps/rest/v1/ e http://developer.yahoo.com/maps/. Não recebi nenhum link que tenha código para integrar o mapa do Yahoo em um site do ASP.NET!

Foi útil?

Solução

Eu criei o mapa dinâmico do Yahoo, o endereço pode ser passado como valor de um campo oculto presente na página. O valor para o campo oculto pode ser passado dinamicamente no evento Page_load. Eu criei isso na página infantil encapsulada pela Página Master no ASP.NET.

Antes de iniciar, o usuário precisa gerar ID do aplicativo para o uso do Yahoo Maps, fazendo login no seu ID do Yahoo e navegando para este link https://login.yahoo.com/config/login_verify2?.src=devNet&.done=http://developer.apps.yahoo.com/wsregapp/ e fornecendo o URL do nosso site.

O código para exibir o mapa do Yahoo é fornecido abaixo:

.map {altura: 400px; Largura: 700px; Fonte-família: Verdana; Size da fonte: 11px; intensidade da fonte: Negrito; }

<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>

Nota: Limitação da taxa: o Yahoo! A API do Ajax Maps é limitada a 50.000 consultas por IP por dia. Verifique este linkhttp://developer.yahoo.com/search/rate.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top