OpenLayers OpenLayers

Yahoo Layer


How To Include a Yahoo Layer in OpenLayers

For a working example of a Yahoo Layer in OpenLayers, see examples/yahoo.html, running live from the repository.

  • Create App ID
    The first thing you need to do is to create a unique Yahoo App ID for your site. You can create the key on the Yahoo Maps App ID Registration Page.
  • Include Yahoo Script
    Once you have created your Yahoo App ID, you are ready to include the Yahoo script on your page. In your HTML page, just before you include the OpenLayers.js script, you need to include the Yahoo script, with your Yahoo App ID set as the "appid" parameter.
    For example, if your Yahoo App ID is: abcdefg1234 then you would include the following:
        <script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=abcdefg1234'></script>
        <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    
  • Create the Yahoo Layer
    Once you have correctly loaded the Yahoo script, you can create a new Yahoo Layer and add it to your Map.
    The code should look something like this:
        var map = new OpenLayers.Map("mapDiv"); 
        var yLayer= new OpenLayers.Layer.Yahoo("Yahoo");
        map.addLayer(yLayer);