javascript - call a php variable in createmarker function -


i'm parsing php xml file , i'm trying put marker in every $item.
error i'm getting : 'uncaught syntaxerror: unexpected string' in these lines

    function createmarker( '<?php echo $item['temp']; ?>',latlng,cold ) { var marker = createmarker( '<?php echo $item['temp']; ?>',latlng,cold ); 

here code

    function initialize() {       var mapoptions = {         zoom: 6,         center: new google.maps.latlng( 38.822590,24.653320 )       };       var map = new google.maps.map(document.getelementbyid('map-canvas'),mapoptions);             <?php foreach ( $item_array $item ) : ?>             var latlng = new google.maps.latlng(parsefloat(<?php echo $item['glat']; ?>),                                                 parsefloat(<?php echo $item['glon']; ?>));             if ( '<?php echo $item["temp"] ?>' >= "18 °c" ) {                 alert('<?php  echo $item["temp"]; ?>');                  var marker = createmarker( '<?php echo $item['temp']; ?>',latlng,cold );             }             <?php endforeach; ?>              var cold  = 'weather_icons/pagetos2.png';             function createmarker( '<?php echo $item['temp']; ?>',latlng,cold ) {                 var marker = new google.maps.marker({                 position: latlng,                 map: map,                 icon: cold                 });                 return marker;             }     }     google.maps.event.adddomlistener(window, 'load', initialize); 

any ideas how i'm gonna have succesfull call in createmarker function?

just remove first parameter of function createmarker , work perfectly.

function initialize() {   var mapoptions = {     zoom: 6,     center: new google.maps.latlng( 38.822590,24.653320 )   };   var map = new google.maps.map(document.getelementbyid('map-canvas'),mapoptions);         <?php foreach ( $item_array $item ) : ?>         var latlng = new google.maps.latlng(parsefloat(<?php echo $item['glat']; ?>),                                             parsefloat(<?php echo $item['glon']; ?>));         if ( '<?php echo $item["temp"] ?>' >= "18 °c" ) {             alert('<?php  echo $item["temp"]; ?>');              var marker = createmarker(latlng,cold );         }         <?php endforeach; ?>          var cold  = 'weather_icons/pagetos2.png';         function createmarker( latlng,cold ) {             var marker = new google.maps.marker({             position: latlng,             map: map,             icon: cold             });             return marker;         } } google.maps.event.adddomlistener(window, 'load', initialize); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -