Support » Fixing WordPress » PHP code in javascript (google maps)

  • Hi there,

    I have a wpmu website and I created an extra page template to include queries so i can pull data from another database. It all works fine.

    But when trying to integrate Google maps i see that it is not processing the PHP that’s included in the javascript needed to generate the google map.

    Does anyone know what to do about this?

    See below the code.

    function initialize() {
    if (GBrowserIsCompatible()) {

    // create the map
    map = new GMap2(document.getElementById(“map”));
    $Lat = 0.000000;
    $Lng = 0.000000;
    $query = “query deleted because of its length”;

    $db->query( $query );
    $stad_id = $db->field(0);
    $Lat = $db->field(1);
    $Lng = $db->field(2);
    map.setCenter(new GLatLng( <? echo $Lng.”,”.$Lat ?>), 13);
    map.addControl(new GLargeMapControl3D());
    map.addControl(new GMapTypeControl());

    // add the points
    $query = “query deleted because of its length”;

    $db->query( $query );
    while ( $db->getrow() ){
    echo “point = new GLatLng(“.$db->field(1).”,”.$db->field(2).”);\n”;
    echo “marker = new createMarker(point,\””.$db->field(3).”\”,\”<b>”.$db->field(3).”</b>
    “.$db->field(4).” “.$db->field(5).”, “.$db->field(6).”\”);\n”;
    echo “map.addOverlay(marker);\n\n”;
    // put the assembled side_bar_html contents into the side_bar div
    document.getElementById(“side_bar”).innerHTML = side_bar_html;
    else {
    alert(“Google Maps API is not compatible with this browser”);

  • The topic ‘PHP code in javascript (google maps)’ is closed to new replies.