Domanda

Come visualizzare mappa statica yahoo in GridView se passiamo indirizzo di interrogazione stringa? Inoltre informi come visualizzare dinamica yahoo maps anche. Ho cercato su Yahoo Maps e ottenuto i seguenti link http://developer.yahoo.com/ flash / mappe / examples.html , http://developer.yahoo.com/ mappe / resto / V1 / e http://developer.yahoo.com/maps/. Non ho avuto alcun legame che ha il codice per l'integrazione di yahoo map in un sito web ASP.Net!

È stato utile?

Soluzione

Ho creato yahoo map dinamica, l'indirizzo può essere passato come valore di un campo presente nascosto nella pagina. Il valore per il campo nascosto può essere passato in modo dinamico in Page_Load. Ho creato questo nella pagina figlio incapsulato dalla pagina master in ASP.Net.

Prima di iniziare, l'utente deve generare ID applicazione per l'utilizzo di yahoo maps accedendo al proprio ID Yahoo e la navigazione verso questo link https://login.yahoo.com/config/login_verify2?.src=devnet&.done=http:// developer.apps.yahoo.com/wsregapp/ e fornendo il nostro URL del sito web.

Il codice per la visualizzazione di yahoo map è il seguente:

                   .carta geografica {     altezza: 400px;     larghezza: 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>

NOTA: Rate limiting: Il Yahoo! Mappe AJAX API è limitata a 50.000 query al IP al giorno. Controllare questo link http://developer.yahoo.com/search/rate.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top