JavaScript
  Home arrow JavaScript arrow Page 4 - A Closer Look at Smart Markers with Yahoo!...
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  
Mobile Linux 
App Generation ROI 
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

A Closer Look at Smart Markers with Yahoo! Maps
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-05-06

    Table of Contents:
  • A Closer Look at Smart Markers with Yahoo! Maps
  • Inserting smart markers into a satellite map
  • Dropping smart markers in a regional Yahoo! Map
  • Displaying smart markers on a hybrid Yahoo! Map

  • 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


    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.

       · In this last article of the series, you’ll learn how to include smart markers in...
       · Hi,I am some trouble to use the openSmartWindow in Yahoo maps. My markers should...
       · Thank you for the comments on my article. Concerning your question, you should be...
     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - 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






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