php - cannot display multiple markers in google maps v3 from traceroute result -
i'm newbie in php mysql , google maps v3. have problems in google maps v3. made traceroute web based , map traceroute's result in google maps v3 final project of college education. have try many tutorials didn't work. have tried tutorials in forum nothing worked. problem cannot display multiple markers got location data database. maybe because i'm newbie , not know how do. confuse looping show markers. here code
<?php error_reporting(e_all ^ (e_notice)); ini_set('max_execution_time', 360); $enable_log_user = false; global $ip, $host_name, $host_ip; $host = @$_post['host']; $trace = @$_post['trace']; $self = $_server['php_self']; include("phpsqlajax_dbinfo.php"); $connection = mysql_connect ('127.0.0.1', $username, $password); if (!$connection) { die('not connected : ' . mysql_error());} $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('can\'t use db : ' . mysql_error()); } ?> <!doctype html > <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>php/mysql & google maps example</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> //<![cdata[ </script> </head> <body onload="initialize()"> var pinimage = new google.maps.markerimage ("http://chart.apis.google.com/chart?chst=d_map_xpin_letter_withshadow&chld=pin_star|%e2%80%a2|cc3300|000000|ff9900", new google.maps.size (70, 83), new google.maps.point (0,0), new google.maps.point (10,34)); var pinshadow = new google.maps.markerimage ("http://chart.apis.google.com/chart?chst=d_map_pin_shadow", new google.maps.size (89, 85), new google.maps.point (0, 0), new google.maps.point (12, 35)); var map; function initialize() { var mylatlng = new google.maps.latlng(41.258531,-96.012599); var myoptions = { zoom: 2, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); <!-- var infowindow = new google.maps.infowindow; --> } </script> <form name="tools" action="<?php $self ?>" method="post"> <p><font size="2">your ip <?php $ip ?> </font></p> <input type="text" name="host" value=""></input> <input type="submit" name="trace" value="traceroute!"></input> </form> <?php if ($_post['submit']) { if (($host == 'enter host or ip') || ($host == "")) { echo '<br><br>you must enter valid host or ip address.'; exit; } if(eregi("^[a-z]", $host)) { $host_name = $host; $host_ip = gethostbyname($host); } else { $host_name = gethostbyaddr($host); $host_ip = $host; } } $host= preg_replace ("[-a-z0-9!#$%&\'*+/=?^_`{|}~]","",$host); $command = "tracert $host"; $fp = shell_exec("$command 2>&1"); $output .= (htmlentities(trim($fp))); echo "<pre>$output</pre>"; echo '<br/>'; $array = array($output); $space_separated = implode(" ", $array); function exploderows($data) { $rowsarr = explode("\n", $data); return $rowsarr; } function explodetabs($singleline) { $parsed = preg_split('/ +/', $singleline); return $parsed; } $data = $space_separated; $rowsarr = exploderows($data); for($a=3;$a<count($rowsarr)-2;$a++) { $linedetails[$a] = explodetabs($rowsarr[$a]); if (empty($linedetails[$a][9])) { $iplist[] = $linedetails[$a][8]; } else { $iplist[] = substr($linedetails[$a][9], 1, -1); } } ($b=0; $b<count($iplist); $b++) { if ($iplist[$b] != "") { $arrline[]=$iplist[$b]; } } function ip_address_to_number($ipaddress) { if ($ipaddress == "") { return 0; } else { $ips = explode (".", "$ipaddress"); return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 * 256); } } for($c=0; $c<count($arrline); $c++) { $integer[] = ip_address_to_number($arrline[$c]); } foreach ($integer $lokasi) { $query = "select cl.locid, cl.country country, cl.region region, cl.city city, cl.postalcode postalcode, cl.latitude latitude, cl.longitude longitude, cl.metrocode metrocode, cl.areacode areacode (select locid idcihuy cityblocks $lokasi between startipnum , endipnum) cb, citylocation cl cb.idcihuy = cl.locid"; $result = mysql_query($query); while ($location = @mysql_fetch_assoc($result)){ $country[] = $location['country']; $region[] = $location['region']; $city[] = $location['city']; $postalcode[] = $location['postalcode']; $latitude[] = $location['latitude']; $longitude[] = $location['longitude']; $metrocode[] = $location['metrocode']; $areacode[] = $location['areacode']; } } ?> <script type="text/javascript"> var point = new google.maps.latlng(<?php echo $latitude ?>, <?php echo $longitude; ?>); var icon = pinimage; var marker = new google.maps.marker({ map: map, position: point, icon: pinimage, shadow: pinshadow }); </script> <div id="map_canvas" style="width: 900px; height: 500px"></div> </body> </html>
okay, here html source code, yes there's wrong seems :
<!doctype html > <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>php/mysql & google maps example</title> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> //<![cdata[ var pinimage = new google.maps.markerimage ("http://chart.apis.google.com/chart?chst=d_map_xpin_letter_withshadow&chld=pin_star|%e2%80%a2|cc3300|000000|ff9900", new google.maps.size (70, 83), new google.maps.point (0,0), new google.maps.point (10,34)); var pinshadow = new google.maps.markerimage ("http://chart.apis.google.com/chart?chst=d_map_pin_shadow", new google.maps.size (89, 85), new google.maps.point (0, 0), new google.maps.point (12, 35)); var map; function initialize() { var mylatlng = new google.maps.latlng(41.258531,-96.012599); var myoptions = { zoom: 2, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); <!-- var infowindow = new google.maps.infowindow; --> } </script> </head> <body onload="initialize()"> <form name="tools" action="" method="post"> <p><font size="2">your ip </font></p> <input type="text" name="host" value=""></input> <input type="submit" name="trace" value="traceroute!"></input> </form> <pre>tracing route detik.com [203.190.242.69] on maximum of 30 hops: 1 * * * request timed out. 2 199 ms 177 ms 179 ms 192.168.36.11 3 385 ms 359 ms 299 ms 192.168.39.8 4 2005 ms 1400 ms 1536 ms 192.168.39.8 5 1857 ms 1277 ms 1874 ms 192.168.36.11 6 2359 ms 3401 ms * 192.168.39.196 7 2477 ms 2641 ms * 114.127.254.78 8 2230 ms 1203 ms 1570 ms 114.127.254.2 9 1595 ms 1642 ms 3005 ms giga-0-0.openixp.net [218.100.27.129] 10 * * * request timed out. 11 * 2517 ms 3294 ms 203.190.244.6 12 1632 ms 2961 ms 1297 ms 203.190.242.69 trace complete.</pre><br/> <script type="text/javascript"> var point = new google.maps.latlng(-5.0000, 120.0000); var icon = pinimage; var marker = new google.maps.marker({ map: map, position: point, icon: pinimage, shadow: pinshadow }); </script> <div id="map_canvas" style="width: 900px; height: 500px"></div> </body> </html>
well, i'm sorry if guys read code. looks mess. because don't know how display code well. important thing want helped in maps. how show markers. looping. google maps doesn't show markers. display maps. masters read question. need possible. i'm sorry if english bad , mistake guys. in advance.
Comments
Post a Comment