homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Correct URL of the gmap new pointer icon in my external JS?
carlozdre

5+ Year Member



 
Msg#: 4386951 posted 12:07 am on Nov 15, 2011 (gmt 0)

I load the js successfully with:

<script src="<?php bloginfo('template_url'); ?>/js/google-map.js" type="text/javascript"></script>

I then have:

var apartments = new google.maps.MarkerImage('/images/apartment-3.png',
new google.maps.Size(129, 42),
new google.maps.Point(0,0),
new google.maps.Point(18, 42)
);


.. and load the apartments var for each POI I show on my Google map.

The paths are /js/google-map.js and /images/apartment-3.png

The js code for Google map display is correct because if I use the js code in the header with

var apartments = new google.maps.MarkerImage('<?php bloginfo('template_url'); ?>/images/apartment-3.png',

for the image URL, it works. If I get the js in the external js file, my icon won't load anymore, even if I use /images/apartment-3.png or images/apartment-3.png for the URL of the new icon, which is normal as my header is on the root of this WP theme.

What am I doing wrong? It's a WordPress platform.

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4386951 posted 6:22 pm on Nov 15, 2011 (gmt 0)

What does template_url echo out as? Compare these two:

....MarkerImage('/images/apartment-3.png', // works
....MarkerImage('<?php bloginfo('template_url'); ?>/images/apartment-3.png', // doesn't

So where does the image reside, at

/images/apartment-3.png

or in the wordpress theme directory?

/wp-content/themes/your-theme/images/apartment-3.png

The leading slash means "start at the domain root."

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved