Home arrow JavaScript arrow Page 4 - A Closer Look at Smart Markers with Yahoo! Maps
JAVASCRIPT

A Closer Look at Smart Markers with Yahoo! Maps


The incorporation of Ajax-based geographical mapping applications, like the popular Yahoo! Maps, into an existing website can help to increase the number of potential visitors. So, if you're a web developer who wants to boost your web site's traffic by working with this powerful Yahoo! Ajax framework, or if you simply want to expand your skills in using its main features, then this series of articles might be what you're looking for.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
May 06, 2008
TABLE OF CONTENTS:
  1. · A Closer Look at Smart Markers with Yahoo! Maps
  2. · Inserting smart markers into a satellite map
  3. · Dropping smart markers in a regional Yahoo! Map
  4. · Displaying smart markers on a hybrid Yahoo! Map

print this article
SEARCH DEVARTICLES

A Closer Look at Smart Markers with Yahoo! Maps - Displaying smart markers on a hybrid Yahoo! Map
(Page 4 of 4 )

In accordance with the concepts that I deployed in the section you just read, I’m going to end this final article of the series by showing you how to incorporate a few smart markers into an existing hybrid Yahoo! Map. This process looks very similar to the one described when working with a regional map, so I won’t bore you with irrelevant explanations about how it works.

Instead, you can save your valuable time and have a close look at the following code sample, which demonstrates how to use the aforementioned smart markers with a selected hybrid 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 using smart markers with an hybrid YAHOO! Map</title>

<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?
v=3.7&appid=YahooDemo"></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 using smart markers with an hybrid YAHOO! Map</h1>

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

<script type="text/javascript">

function initializeMap(){

// Create a new map object

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

// Add type controls to the map

map.addTypeControl();

// Add the Pan Control to the map

map.addPanControl();

// Add slong zoom control to the map

map.addZoomLong();

// Set map type to YAHOO_MAP_HYB

map.setMapType(YAHOO_MAP_HYB);

// Display the map centered on the selected location

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

// Add an event to report to our Logger

YEvent.Capture(map,EventsList.MouseClick,displaySmartMarker);

// display smartMarker

function displaySmartMarker(_e,_c){

var geoPoint=new YGeoPoint(_c.Lat,_c.Lon);

var newMarker= new YMarker(geoPoint);

// call 'autoexpand()' method

newMarker.addAutoExpand('This is a smart marker');

// add HTML to the smart marker

var markerHTML= '<p>This is the markup<br />';

markerHTML+='of the smart marker</p>';

YEvent.Capture(newMarker,EventsList.MouseClick,function()
{newMarker.openSmartWindow(markerHTML)});

map.addOverlay(newMarker);

}

}

window.onload=function(){

initializeMap();

}

</script>

</body>

</html>


As you can see, once again I used a click logger to display different smart markers as the pertinent map is being clicked. Logically, the only difference to spot here is that a hybrid map is used, instead of a regional or a satellite-based one. The rest of the source code remains the same, so you shouldn’t have major trouble understanding how this specific example functions.

Besides, below I included a complementary image that shows how these smart markers are properly displayed on this regional map:



As is usual with many of my articles on web development, feel free to modify the source code of all of the examples developed in this series. This way you can improve your skills in using the Yahoo! Map framework.

Final thoughts

We’ve come to the end of this article series. I hope that all of the code samples that I provided in this group of tutorials will be useful enough to get you started utilizing the most relevant features offered by Yahoo! Maps.

See you in the next web development tutorial!


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.

blog comments powered by Disqus
JAVASCRIPT ARTICLES

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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