JavaScript
  Home arrow JavaScript arrow Page 4 - Adding Zoom Controls to Yahoo! Maps
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Adding Zoom Controls to Yahoo! Maps
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-04-08

    Table of Contents:
  • Adding Zoom Controls to Yahoo! Maps
  • A quick review: building different types of Yahoo! Maps
  • Adding a long zoom control to Yahoo! Maps
  • Using a short zoom control with Yahoo! Maps

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Adding Zoom Controls to Yahoo! Maps - Using a short zoom control with Yahoo! Maps


    (Page 4 of 4 )

    As I stated in the previous section, it’s also feasible to incorporate a “short” zoom control into an existing Yahoo! Map by using another method of the handy “YMap()” JavaScript class, called “addShortZoom().”

    This method supports practically the same implementation as its counterpart “long” and can be seen in action in the following hands-on example:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <title>Example on building a YAHOO! Map with short zoom control</title>

    <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.7&appid=Your-
    AP-ID"></script>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: bold 16pt Arial, Helvetica, sans-serif;

    color: #000;

    text-align: center;

    }

    #mapcontainer{

    height: 400px;

    width: 500px;

    margin-left: auto;

    margin-right: auto;

    }

    </style>

    </head>

    <body>

    <h1>Example on building a YAHOO! Map with short zoom control</h1>

    <div id="mapcontainer"></div>

    <script type="text/javascript">

    // Create a new map object

    var map=new YMap(document.getElementById('mapcontainer'));

    // Add type controls to the map

    map.addTypeControl();

    // Add short zoom control to the map

    map.addZoomShort();

    // Set map type to YAHOO_MAP_SAT

    map.setMapType(YAHOO_MAP_SAT);

    // Display the map centered on the selected location

    map.drawZoomAndCenter("Los Angeles",3);

    </script>

    </body>

    </html>


    As you can see, displaying a “short” zoom control on a selected Yahoo! Map is only a question of calling the appropriate JavaScript method of the pertinent “YMap” class. In this case, the mentioned control is added before specifying the type of map that should be constructed. Pretty simple to grasp, isn’t it?

    In addition, you may want to look at the following screen shot, which shows the visual appearance of the previously mentioned zoom control:



    As shown in the above image, the short zoom control is composed basically of two small arrows for zooming in and out on the targeted Yahoo! Map. Of course, it’s up to you to decide what zoom control best suits your needs, according to the specific requirements of the web application that will use these interactive maps.

    Final thoughts

    That’s all for now. In this second part of the series, I demonstrated how to incorporate two different zoom controls into an existing Yahoo! Map, making it much more functional and usable.

    However, I’m only scratching the surface when it comes to exploring the numerous features packaged with the Yahoo! Map Ajax framework. Thus, in the next article, you’ll learn how to incorporate some useful pan controls into a given map, providing it with the capacity to scroll all over a selected geographical location.

    Now that you’re aware of the topics that will be discussed in the upcoming article of this series, you won't want to miss it!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Yahoo! Maps support working with two basic zoom controls, called "short" and "long"...
     

    JAVASCRIPT ARTICLES

    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway