YUI + Yahoo Maps Ajax JS dont get along

If you're using yahoo's ajax api you include a js file at the top of your page that loads much of the JS needed.  This code conflicts with parts of YUI. 

<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=yourstuffhere"></script>

I use ColdFusion which includes YUI in some of its UI controls.  Two things I have found thus far that don't work. 

CFLayout collapse -   The collapse option simply doesn't work.  NO JS errors.

CFInput: Autocomplete - Throws the error yahoo.utils.dom.inDocument is not a function or something very similar.  Perhaps a similarly named var is within the maps js file?

I am just finishing the cf.objective conf, and have limited bandwidth / focus atm so not much more testing to be done.  My best guess: ColdFusion includes all its UI js files before any others.  So the yahoo ajax api will overwrite its functions and thus it isn't likely to work.  I will file an error report to yahoo, as its their two js files that are conflicting ironically.

Time to play with jquery clearly. :-)

Update: minutes after posting I found this post that confirms the issue an a workaround. Perhaps I can find a newer version of the maps api? 

TweetBacks
Comments
davidbuhler's Gravatar What I found is this:
1) You always want to move the Yahoo Maps JS file to the bottom of the page. This allows the page to load much faster, because of the parallel download issues with JS files and CSS files (but not their images). Also, The Yahoo maps images are expensive and heavy, so I always want them last. I highly suggest calling the loading of the Yahoo maps with setTimeOut() in JS (wrapping it in a function), so you can spare users the wait and the toll on the OS stack that accompanies the JS initialization.

You'll reduce your download times as well, by including whatever JS files you can in the page, rather than externalizing them. Caching them is worthwhile..if they are enormous libraries, otherwise, you can wait an 500MS for a 4KB JS file.

The CFLayout tags are dated already, and I, personally, want more granular control over my frameworks. I suggest using Spry, EXTJS, YUI, etc, but with the custom files instead of the standard CF Files. This way, you can easily control the load order. For example, MooTools does not get along with EXTJS, unless you change the order (so MooTools loads last). Spry 1.6 is unobtrusive to some degree, but the older Spry versions are not, and this will slow you down in development. CF8 uses an older version of Spry. MooTools and Prototype don't get along well, and EXTJS, combined with Prototype requires you load each in a specific order. And even then, you can run into a race conditions because of the parallel download stream issue with JS files.

If you're really haunted by the Maps code for Yahoo, you can use the Flash Maps from Yahoo which can reduce CPU burden and would have no interference with the Ajax frameworks.
# Posted By davidbuhler | 5/4/08 6:31 PM
joshua's Gravatar Hi David,

Thanks so much for the detailed comment. I do use YUI now in other projects, but am new to yahoo maps ajax api. Its working pretty well save the issue above, but I will review everything you mention and continue to refine.
# Posted By joshua | 5/5/08 1:36 PM
Eric Miraglia's Gravatar http://yuiblog.com/blog/2006/12/14/maps-plus-yui/

Sorry this is still a problem. If you follow the link above, I've tried to articulate the solution -- this solution is still current for the latest version of YUI (2.5.2) and the latest version of the Yahoo Maps Ajax API.
# Posted By Eric Miraglia | 6/27/08 1:54 AM
upender's Gravatar Hi all,
I am facing problem with this.When i am putting all the functions on .aspx page it works fine.But if i put the functions in separate .js file it gives error and display no marker.
# Posted By upender | 12/9/08 6:00 AM

NAVIGATION

Home
About Me

RSS


Search

Subscribe

Enter your email address to subscribe to this blog.

Recent Entries

Flash Camp Boston
New Blog Design
Pre-Conference Training at cf.Objective()
FireFox 3.6 KTML Editor Fix
I am now a part of the Adobe Community Professionals Group

Recent Comments

FireFox 3.6 KTML Editor Fix
Fred said: Found another bug in Firefox 3.6 When inserting a table you can't select the number of columns. So I... [More]

Repeating Events Question
ueghbxedu said: UaejcB <a href="http://ysyhrmkbkhco.com/&...;, [url=http://pwncz... [More]

Repeating Events Question
fadxkfyuadn said: n6qVCL <a href="http://bdiorhdtbwzb.com/&...;, [url=http://uvnao... [More]

FireFox 3.6 KTML Editor Fix
Joshua said: While changing that far will load the editor, does it show the drop down class menu correctly now? [More]

FireFox 3.6 KTML Editor Fix
Al Johnson said: HI, I am still fighting to keep my code going as there is nothing better than KTML nad I have writt... [More]

Calendar

Sun Mon Tue Wed Thu Fri Sat
 123456
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31    

Archives By Subject

blogs (31) [RSS]
books (4) [RSS]
Crazy (39) [RSS]
DIY (8) [RSS]
Flex (3) [RSS]
games (10) [RSS]
GRRR (13) [RSS]
Ideas (11) [RSS]
Local (14) [RSS]
LOLpics (2) [RSS]
money (9) [RSS]
music (3) [RSS]
Personal (27) [RSS]
Photos (8) [RSS]
Politics (8) [RSS]
Projects (22) [RSS]
Review (18) [RSS]
RPM (9) [RSS]
Spam (16) [RSS]
Technology (66) [RSS]
Testing (3) [RSS]
TV (15) [RSS]
video (32) [RSS]
Web Dev (218) [RSS]
World of Warcraft (16) [RSS]