Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8036923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:46:35+00:00 2026-06-05T02:46:35+00:00

I’m newbie in php mysql and google maps v3. I have a problems in

  • 0

I’m newbie in php mysql and google maps v3. I have a problems in google maps v3. I made traceroute web based and map the traceroute’s result in the google maps v3 for my final project of my college education. I have try so many tutorials but it didn’t work. I also have tried the tutorials in this forum but nothing worked. So my problem is I cannot display multiple markers that I got the location data from database. maybe because I’m newbie and do not know how to do. I also confuse with the looping to show the markers. So here is the php code:

<?php
error_reporting(E_ALL ^ (E_NOTICE));
ini_set('max_execution_time', 360);
$enable_log_user = FALSE;

global $ip, $host_name,  $host_ip, $output, $integer;

$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());
} 

function get_ip()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

$ip = get_ip(); 

?>
<!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()">
<form name="tools" action="<?php $self ?>" method="post">
    <p><font size="2">Your IP is <?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 a 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);
        }
    }

    for ($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]);
}

    ?>
    <script type="text/javascript">
        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
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    <?php
    $posisi = array();
    foreach ($integer as $lokasi) {
    $query = "SELECT cl.locId, cl.country as country, cl.region as region, cl.city as city, cl.postalCode as postalCode, cl.latitude as latitude, cl.longitude as longitude, cl.metroCode as metroCode, cl.areaCode as areaCode
    FROM (SELECT locId as idcihuy FROM cityblocks WHERE $lokasi BETWEEN startIpNum AND endIpNum) cb, citylocation cl WHERE cb.idcihuy = cl.locId";
    $result = mysql_query($query);
    while ($location = @mysql_fetch_assoc($result)){
    $posisi[]= 'new google.maps.LatLng(' . $location['latitude'] . ', ' . $location['longitude'] . ')';
    }
    }
    ?>
    <!-- var infoWindow = new google.maps.InfoWindow; -->
     var point = [<?php echo implode(',', $posisi) ?>];
     var icon = pinImage;
     var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: pinImage,
        shadow: pinShadow
        });
             marker.setMap(map);
        }
    </script>
<div id="map_canvas" style="width: 900px; height: 500px"></div>
</body>
</html>

And this is the html code:

<!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()">

<form name="tools" action="" method="post">

    <p><font size="2">Your IP is  </font></p>

    <input type="text" name="host" value=""></input>

    <input type="submit" name="trace" value="Traceroute!"></input>

    </form>

    <pre>Tracing route to youtube-ui.l.google.com [173.194.38.129]
over a maximum of 30 hops:

  1   204 ms   238 ms   233 ms  192.168.1.1 
  2   992 ms   241 ms   200 ms  192.168.1.11 
  3   852 ms   239 ms   502 ms  192.168.4.36 
  4  1079 ms   257 ms   281 ms  192.168.4.36 
  5   856 ms   321 ms   306 ms  192.168.1.11 
  6     *        *        *     Request timed out.
  7  1073 ms   239 ms   198 ms  205.128.240.180.telin.sg [180.240.128.205] 
  8   216 ms   292 ms   281 ms  109.190.240.180.telin.sg [180.240.190.109] 
  9   239 ms   239 ms   299 ms  72.14.215.170 
 10  1838 ms   539 ms   508 ms  209.85.243.158 
 11   467 ms   998 ms  1098 ms  72.14.233.79 
 12  1601 ms   239 ms     *     sin04s01-in-f1.1e100.net [173.194.38.129] 
 13   790 ms   356 ms   179 ms  sin04s01-in-f1.1e100.net [173.194.38.129] 

Trace complete.</pre><br/>  <script type="text/javascript">

        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

    }

    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        <!-- var infoWindow = new google.maps.InfoWindow; -->

     var point = [new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574)];

     var icon = pinImage;

     var marker = new google.maps.Marker({

        map: map,

        position: point,

        icon: pinImage,

        shadow: pinShadow

        });

        marker.setMap(map);

        }

    </script>

<div id="map_canvas" style="width: 900px; height: 500px"></div>

</body>

</html>

Well, I’m really sorry if you guys read my code. It looks mess. Because I don’t know how to display the code well. The most important thing I want to be helped is in the maps. For how to show all the markers. Especially the looping. The google maps doesn’t show the markers. It only display the maps. So for all the masters who read this question. I just need your help as soon as possible. I’m really sorry if my English was bad and my mistake to you guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:46:37+00:00Added an answer on June 5, 2026 at 2:46 am

    The problem is you’re not giving your markers any position:

     var point = [];
     var icon = pinImage;
    
     var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: pinImage,
        shadow: pinShadow
        });
    

    So all you’ve done is create the position as an empty array. You need to create a LatLng() there for the position instead.


    So now you’ve got an array of points:

     var point = [new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574)];
    
     var icon = pinImage;
    
     var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: pinImage,
        shadow: pinShadow
        });
    
        marker.setMap(map);
    

    What you need to do is loop over the array, creating a marker for each:

    var point = [new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(1.3667, 103.8000),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574),new google.maps.LatLng(37.4192, -122.0574)];
    
    var icon = pinImage;
    
    for (var i = 0; i < point.length; i++) {
         var marker = new google.maps.Marker({
            map: map,
            position: point[i],
            icon: pinImage,
            shadow: pinShadow
            });
    }
    

    Also the setMap line is redundant, because when you say map:map, that is all you need to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.