JS array problem
-
Hi,
I’m writing plugin with Google Maps and I have a code:
function show_all( id ) { var url = '../wp-content/plugins/GoogleMaps/xml_gen.php?id='+id; var markers_arr = []; GDownloadUrl( url, function( data, response ) { var xml = GXml.parse( data ); var markers = xml.documentElement.getElementsByTagName( "marker" ); map.setCenter( new GLatLng( parseFloat( markers[0].getAttribute( "lat" ) ), parseFloat( markers[0].getAttribute( "lng" ) ) ), 12 ); for( var i = 0; i < markers.length; i++ ) { var point = new GLatLng( parseFloat( markers[i].getAttribute( "lat" ) ), parseFloat( markers[i].getAttribute( "lng" ) ) ); var marker = new GMarker( point ); markers_arr[i] = marker; marker.txt = markers[i].getAttribute( "etiq" ); map.addOverlay( marker ); } } ); for( var j = 0; j < markers_arr.length; j++ ) { alert( markers_arr[j].getPoint() ); document.getElementById( "status" ).innerHTML += markers_arr[j].getPoint()+" "; } }
It is in admin.js file and is used only by Administrator pages. The problem is with arrays because I can’t see any alert after invoking this function. What’s wrong with it? When I have i simple HTML page it works. I include JS code in this way:
add_action( 'admin_print_scripts', array( &$gm, 'JSAdminOutput' ) );
And method JSAdminOutput looks like this:
public function JSAdminOutput() { echo "<script type='text/javascript' src='".get_option( 'siteurl' )."/wp-content/plugins/GoogleMaps/js/admin.js'></script>"; echo "<script src='http://maps.google.com/maps?file=api&v=2&key=".($this->api_key)."' type='text/javascript'></script> "; }
Thanks for any responses and tips 🙂
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘JS array problem’ is closed to new replies.