WordPress.org

Ready to get started?Download WordPress

Forums

How to call on different javascript functions in the header.php?? (1 post)

  1. syrinx32123
    Member
    Posted 1 year ago #

    Hi,

    I have a javascript in my header that pulls in a google map:

    <script type="text/javascript">
    		function initialize() {
    			var latlng = new google.maps.LatLng(57.0442, 9.9116);
    		var settings = {
    			zoom: 15,
    			center: latlng,
    			mapTypeControl: true,
    			mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
    			navigationControl: true,
    			navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
    			mapTypeId: google.maps.MapTypeId.ROADMAP
        };
    
    var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
    
    }
    </script>

    In the body of the post I'm using

    <body>
    
    <body onload="initialize()">
      <div id="map_canvas" style="width:400px; height:500px"></div>
    </body>

    to call on the JS and display a map in the post. The only problem with this is that I can only display one map with one location.

    I have two separate posts that I would like to use two separate maps for... one map centered on LA and the other centered on NYC

    How can I make a variable in the header so that I can call on the LA map for one post, and the NYC map for another post?

    Please help! I have very limited knowledge of WP

    http://www.travelgrom.com/test-4-name-test/

Topic Closed

This topic has been closed to new replies.

About this Topic