Include javascript in node myjavascript.js:

    function initialize() {

        var waStyle = [
            {
                featureType: "all",
                stylers: [
                    { saturation: -100 }
                ]
            }
        ];

        var mysiteMap = new google.maps.StyledMapType(waStyle,{name: "Nuance"});

        var img = new google.maps.MarkerImage("/themes/nuance/img/pin.png");

        var myLatlng = new google.maps.LatLng(41.061833,28.997948);

        var mapOptions = {
            zoom: 16,
            center: myLatlng,
            disableDefaultUI: true,
            mapTypeControlOptions: {
                mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'mysite_map'],
            }
        };

        var map = new google.maps.Map(document.getElementById('mainmap'), mapOptions);

        var point = new google.maps.LatLng(41.061833,28.997948);
        var marker = new google.maps.Marker({
            position: point,
            map: map,
            animation: google.maps.Animation.DROP,
            icon: img
        })

        map.mapTypes.set('mysite_map', mysiteMap);
        map.setMapTypeId('mysite_map');
    }

    function loadScript() {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://maps.googleapis.com/maps/api/js?sensor=false&amp;callback=initialize";
        document.body.appendChild(script);
    }

    window.onload = loadScript;


And include in my node via field. (text format: php code)

&lt;?php include('themes/mytheme/scripts/maps/myjavascript.js'); ?&gt;


But get error.

On site:

 function initialize() { var waStyle = [ { featureType: "all", stylers: [ { saturation: -100 } ]
    ...


What's my problem and how can i fix it?
The Drupal way is to add js on the go is drupal_add_js

drupal_add_js($data = NULL, $options = NULL)


Examples:

  drupal_add_js('misc/collapse.js');
  drupal_add_js('misc/collapse.js', 'file');
  drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
  drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });',
    array('type' =&gt; 'inline', 'scope' =&gt; 'footer', 'weight' =&gt; 5)
  );
  drupal_add_js('http://example.com/example.js', 'external');
  drupal_add_js(array('myModule' =&gt; array('key' =&gt; 'value')), 'setting');


There is a better way to add a library file drupal_add_library

Parameters


$module:
The name of the module that registered the library.

$name:
The name of the library to add.

$every_page:
Set to TRUE if this library is added to every page on the site. Only items
with the every_page flag set to TRUE can participate in aggregation.