Home arrow JavaScript arrow Page 2 - Adding Pan Controls to Yahoo! Maps
JAVASCRIPT

Adding Pan Controls to Yahoo! Maps


Welcome to the third chapter of the series “Working with Yahoo! Maps.” If you’re an enthusiastic web developer who wants to incorporate these powerful interactive maps into your own web site, then in this article series, you’ll find a step-by-step guide on how to implement their features, including numerous hands-on examples.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
April 15, 2008
TABLE OF CONTENTS:
  1. · Adding Pan Controls to Yahoo! Maps
  2. · Review: including short and long zoom control into an existing Yahoo! Map
  3. · Incorporating a useful pan control into a Yahoo! Map
  4. · Displaying a Yahoo! Map with zoom and pan controls

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Adding Pan Controls to Yahoo! Maps - Review: including short and long zoom control into an existing Yahoo! Map
(Page 2 of 4 )

As I stated in the beginning of this article, my goal here consists basically of demonstrating how to include some pan controls into a given Yahoo! Map. But do you really remember how to add zoom capabilities also? Good question! So, before I show you how a pan mechanism can be incorporated to a selected map, first let me remind you of the steps required to include both short and long zoom controls.

Please take a look at the following code samples, which were developed in the preceding article of the series, to recall how to provide an existing Yahoo! Map with powerful zoom capabilities:

(example on including a long zoom control into an existing regional Yahoo! Map)


<!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 long 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 long 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 long zoom control to the map

map.addZoomLong();

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



(example on including a short zoom control into an existing regional Yahoo! Map)


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


After studying the above practical examples, I’m reasonably sure that you're familiar with including both short and long zoom controls into any targeted Yahoo! Map. The means that it’s time to continue exploring some other features that come packaged with the Yahoo! Map Ajax framework.

I’m going to teach you how to display a set of handy pan controls on a given map. But as you might guess, to learn more on this interesting topic, you’ll have to read the next section. Don’t you worry, since I’ll be there waiting for you.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials