SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    p h p b o a r d+s q l+x m l+google map api v3 problem!!

    I`m a beginner about xml,google map api v3

    But I try to make a google map + php board+sql+xml



    Everything is good..But..
    this line I can`t handel it.
    ------------------------------------
    Code XML:
    <contents>
    <![CDATA[ <img src="./data/file/xmltest/3031146274_Gs1ATViN_3-2-2.jpg"width='200'><br><a href="">Web Page Link </a><br>ABCDEFG
      ]]> 
      </contents>
    --------------------------------------------------------------------------

    I want to print this line on php .But it doesn`t working..

    I can`t see anything on main.php file

    What happen?? It doesn`tworking with google map api v3?

    Or any problem with my php file?

    Plz help me out.
    I have two php file and xml


    ##################This is Xml #########################################


    Code XML:
    <markers>
    <marker label="testlabel" lat="37.548933000000" lng="127.139988000000" html="htmltest" address="addresstest" name="subjest" image="../data/file/xmltest/3031146274_Gs1ATViN_3-2-2.jpg" width="200">
    <contents>
    <![CDATA[ <img src="./data/file/xmltest/3031146274_Gs1ATViN_3-2-2.jpg"width='200'><br><a href="">Web Page Link </a><br>ABCDEFG
      ]]> 
      </contents>
      </marker>

    ######################### main.php ########################################


    Code PHP:
    <script type="text/javascript" src="downloadxml.js"></script>
    <style type="text/css"> 
    html, body { height: 100%; } 
    </style>
    <script type="text/javascript"> 
    //<![CDATA[
          // this variable will collect the html which will eventually be placed in the side_bar 
          var side_bar_html = ""; 
          var contentString = [];
          // arrays to hold copies of the markers and html used by the side_bar 
          // because the function closure trick doesnt work there 
          var gmarkers = []; 
     
         // global "map" variable
          var map = null;
    // A function to create the marker and set up the event window function 
     
    function createMarker(latlng, name, html, image, address, type) { 
        var contentString = html + image + address + type;
     
        var marker = new google.maps.Marker({
            icon: 'monumento.png',
    		position: latlng,
            map: map,
            zIndex: Math.round(latlng.lat()*-100000)<<5
            });
     
        google.maps.event.addListener(marker, 'click', function() {
            infowindow.setContent(contentString); 
            infowindow.open(map,marker);
            });
        // save the info we need to use later for the side_bar
        gmarkers.push(marker);
        // add a line to the side_bar html
        side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name  + '<\/a><br>';
    }
     
    // This function picks up the click and opens the corresponding info window
    function myclick(i) {
      google.maps.event.trigger(gmarkers[i], "click");
    }
     
    function initialize() {
      // create the map
      var myOptions = {
        zoom: 8,
        center: new google.maps.LatLng(37.558323,127.14632),
        mapTypeControl: true,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      map = new google.maps.Map(document.getElementById("map_canvas"),
                                    myOptions);
     
      google.maps.event.addListener(map, 'click', function() {
            infowindow.close();
            });
          // Read the data from example.xml //
     
          downloadUrl("example.xml", function(doc) {
            var xmlDoc = xmlParse(doc);
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            for (var i = 0; i < markers.length; i++) {
              // obtain the attribues of each marker
              var lat = parseFloat(markers[i].getAttribute("lat"));
              var lng = parseFloat(markers[i].getAttribute("lng"));
              var point = new google.maps.LatLng(lat,lng);
    		  var name = markers[i].getAttribute("name")+ '<br />';
              var html = markers[i].getAttribute("html")+ '<br />';
              var label = markers[i].getAttribute("label");
    		  var address = markers[i].getAttribute("address")+ '<br />';
    		  var type = markers[i].getAttribute("type")+ '<br />';
    		  var image = '<a href=\""><img src="'+markers[i].getAttribute("image")+'" alt=""  width="150" height="140" border="0"/><\/a>'+ '<br />';
              // create the marker
              var marker = createMarker(point,label,name,html,image,address,type);
            }
            // put the assembled side_bar_html contents into the side_bar div
            document.getElementById("side_bar").innerHTML = side_bar_html;
          });
        }
     
    var infowindow = new google.maps.InfoWindow(
      { 
        size: new google.maps.Size(150,50)
      });
     
     
        // This Javascript is based on code provided by the
        // Community Church Javascript Team
        // http://www.bisphamchurch.org.uk/
        // http://econym.org.uk/gmap/
        // from the v2 tutorial page at:
        // http://econym.org.uk/gmap/basic3.htm
    //]]>
    </script> 
     
      </head> 
    <body style="margin:0px; padding:0px;" onload="initialize()" > 
     
        <!-- you can use tables or divs for the overall layout --> 
        <table border="1"> 
          <tr> 
            <td> 
               <div id="map_canvas" style="width: 1000px; height: 800px"></div> 
            </td> 
            <td valign="top" style="width:150px; text-decoration: underline; color: #4444ff;"> 
               <div id="side_bar"></div> 
            </td> 
          </tr> 
        </table>
    ############################### This file make a xml file automatically #################################

    Code PHP:
    <?
     
     
     
    $laguage_ = "utf-8"; 
     
    //$xml_dir  = $g4[path]."/xml/banner/".$po_poll1; //
    //$xml_path = $xml_dir."/".$po_poll1.".xml";
     
    //
    $xml_dir  = $g4[path]."/xml_banner"; //
    $xml_path = $xml_dir."/example.xml";
     
    @mkdir($xml_dir, 0707);
    @chmod($xml_dir, 0707);
     
     
    if(!$xml_path){
    fwrite($xml_file, "");
    fclose($xml_file);
    @chmod($xml_path, 0707);
    }
     
    $xml_file = fopen($xml_path, "w+")or die("xml file open erro.");
     
     
    //xml 갱싱
    $rows              = 20;
    $sql              = " select * from $write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    $result           = sql_query($sql);
    $total_count      = mysql_num_rows($result);
     
    $data[lauage]       = "<markers>";  
     
     
    $data[xml_start]    = "";
     
    $data[xml_end]      = "</marker>";
     
    $get_xml   = "";
     
    $get_xml  .= $data[lauage];
     
     
          while ($list= sql_fetch_array($result)){ 
     
           $get_sql = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '{$list[wr_id]}' and bf_no = 0 ";
           $img_row = sql_fetch($get_sql);
     
     
     
    	   if($img_row[bf_file]){
    		 $img_path  = "./data/file/$bo_table";
    		 $img_path .= "/".$img_row[bf_file];
     
             $get_xml  .= $data[xml_start];
     
    	     $view_subject = conv_subject($list[wr_subject], 50, "");
             $view_content = conv_content($list[wr_content], 90, "");
    		 $wr_9 = get_text($row[wr_9]);     
             $wr_10 = get_text($row[wr_10]); 
    		 $wr_7 = get_text($row[wr_7]); 
    		 $wr_8 = get_text($row[wr_8]); 
    		 $get_xml    .= "<marker label=\"{$view_subject}\" lat=\"{$list[wr_9]}000000\" lng=\"{$list[wr_10]}000000 \" html=\"{$list[wr_7]}\" address=\"{$list[wr_8]}\" name=\"{$view_subject}\" image=\"{$img_path}\" width='200'><contents><![CDATA[<img src=\"{$img_path}\"width='200'><br><a href=\"{$list[wr_link1]}\">Web Page Link </a><br>{$view_content}]]></contents>";
    		 $get_xml    .= $data[xml_end];
     
    	   } 
    	  } 
     
     
     
    $get_xml      .= "</markers>";	
     
    /****************************xml data end**************************/
     
    //변환
    $get_xml = iconv("utf-8", "utf-8",$get_xml); 
     
    // write action
    if(!fwrite($xml_file, $get_xml)) echo "file wite erro.";
     
    // file close
    fclose($xml_file);
     
    ?>
    Last edited by Mittineague; Jan 27, 2012 at 22:51. Reason: reformatting bbcode tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •