Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    New Coder
    Join Date
    Feb 2009
    Location
    Mosjøen, Norway
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mapping script help!

    Hey there!

    I wanted to make a mapping script where you have 4x4 regions with 124x124 squares in every region, with their own unique coordinates.

    Here's a reference image of what I mean.


    That's where my problems start, I've not really got much of a clue on to where or how to start doing this.

    I wanted it to be dynamical because, when members and users input their coordinates, it'd get saved in mysql and when you access the different map regions they would get loaded and put in their correct place on the map. Empty spaces being blank.

    Any help at all would be massively appreciated.

    Cheers,
    - Mentally.

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    this is quite a big project for this HELP forum my friend. Even I must turn you down.

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    ARGH i ant help it...
    right you will have to create 16 scripts to generate 124 X 124 cell tables (before anyone says anything i know). After you have created them you will have to use CSS to align them correctly. After more thought you will find you can now your script down to just one script and send it through a loop.... i might start you on your way... if your nice.

  • #4
    New Coder
    Join Date
    Feb 2009
    Location
    Mosjøen, Norway
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hehe, well, I actually thought it would be a lot easier than it sounds.

    But the real problem I think really is just how to make the 124x124 grid when you click on a region.

  • #5
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    just an idea
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ACT Web Designs - Home</title>
    <style type="text/css">
        table.table {
            float:left;
        }
        div.clear {
            clear:both;
        }
        #wrapper {
            width:1500px;
        }
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php

    $colors16 
    = array("red""blue""green""orange""brown""black""white""pink""purple""yellow""green""red""orange""brown""pink""purple""yellow");

    for(
    $y 0$y <= 15$y++)
    {
        echo 
    "<table class=\"table\" name=\"start_".($y*124)." style=\"paddong:0; margin:0\" cellpadding=\"0\">\n";
        for(
    $x 1$x <= 124$x++)
        {
            echo 
    "<tr style=\"paddong:0; margin:0; background-color:".$colors16[$y]."\">";
            for(
    $z 1$z <= 124$z++)
            {
                echo 
    "<td name=\"".$y."-".($x*$z)."\" width=\"1px\" height=\"1px\" style=\"paddong:0; margin:0\" cellpadding=\"0\"></td>\n";    
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>\n";
    }

    ?>
    <div class="clear"></div>
    </div>
    </body>
    </html>
    Last edited by Phil Jackson; 08-27-2009 at 11:41 PM.

  • #6
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    be warned its time consuming. thousands of lines of outputted code.

  • #7
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    think my calcs are wrong...
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ACT Web Designs - Home</title>
    <style type="text/css">
        table.table {
            float:left;
        }
        div.clear {
            clear:both;
        }
        #wrapper {
            width:900px;
        }
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php

    $colors16 
    = array("red""blue""green""orange""brown""black""white""pink""purple""yellow""green""red""orange""brown""pink""purple""yellow");

    for(
    $y 0$y <= 15$y++)
    {
        echo 
    "<table class=\"table\" name=\"start_".($y*62)." style=\"padding:0; margin:0\" cellpadding=\"0\">\n";
        for(
    $x 1$x <= 62$x++)
        {
            echo 
    "<tr cellpadding=\"0\" style=\"padding:0; margin:0;  background-color:".$colors16[$y]."\">";
            for(
    $z 1$z <= 62$z++)
            {
                echo 
    "<td name=\"".$y."-".($x*$z)."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0\" cellpadding=\"0\"></td>\n";    
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>\n";
    }

    ?>
    <div class="clear"></div>
    </div>
    </body>
    </html>

  • #8
    New Coder
    Join Date
    Feb 2009
    Location
    Mosjøen, Norway
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's really awesome, Phil. It's exactly what I'm looking for and a really huge leap in the right direction for me.

    Now all I'm looking at is to get some kind of visual representation for all the 16 "fields" and grabbing any coordinate points added from the database and display them accordingly when viewing a region for example. (Could possibly just leave the rest of the fields blank inheriting the background color with a border around or something.)

    But so far you've been really awesome. Thanks a lot for your help.

    I'll try and see if I can develop this little script further now.

  • #9
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    not to be a stuck in the mud but see if this helps:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ACT Web Designs - Home</title>
    <style type="text/css">
        table.table {
            float:left;
        }
        div.clear {
            clear:both;
        }
        #wrapper {
            width:900px;
        }
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php

    $colors16 
    = array("red""blue""green""orange""brown""black""white""pink""purple""yellow""green""red""orange""brown""pink""purple""yellow");

    for(
    $y 0$y <= 15$y++)
    {
        echo 
    "<table class=\"table\" name=\"start_".($y*62)." style=\"padding:0; margin:0\" cellpadding=\"0\">\n";
        for(
    $x 1$x <= 62$x++)
        {
            echo 
    "<tr cellpadding=\"0\" style=\"padding:0; margin:0; \">";
            for(
    $z 1$z <= 62$z++)
            {
                if(isset(
    $_POST['x']))
                {
                    
    $coOrd $_POST['y']."-".$_POST['x']."-".$_POST['z'];    
                    
    $tdName = ($y+1)."-".$x."-".$z;
                    if(
    $coOrd==$tdName)
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color: black\" cellpadding=\"0\"></td>\n";
                        die(
    "");
                    }
                    else
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";
                    }
                }
                else
                {
                    echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";    
                }
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>\n";
    }

    ?>
    <div class="clear"></div>
    </div>
    <form action="1.php" method="post">
    <p>y - (box 1 - 16) <input type="text" name="y" /></p>
    <p>X - <input type="text" name="x" /></p>
    <p>Z - <input type="text" name="z" /></p>
    <input type="submit" name="submit" />
    </form>
    </body>
    </html>

  • #10
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    quite an interesting project. You'll notice that the script will stop at that exact co-ord

  • #11
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    This will give a cross ref effect:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ACT Web Designs - Home</title>
    <style type="text/css">
        table.table {
            float:left;
        }
        div.clear {
            clear:both;
        }
        #wrapper {
            width:900px;
        }
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php

    $colors16 
    = array("red""blue""green""orange""brown""black""white""pink""purple""yellow""green""red""orange""brown""pink""purple""yellow");

    for(
    $y 0$y <= 15$y++)
    {
        echo 
    "<table class=\"table\" name=\"start_".($y*62)." style=\"padding:0; margin:0\" cellpadding=\"0\">\n";
        for(
    $x 1$x <= 62$x++)
        {
            echo 
    "<tr cellpadding=\"0\" style=\"padding:0; margin:0; \">";
            for(
    $z 1$z <= 62$z++)
            {
                if(isset(
    $_POST['x']))
                {
                    
    $coOrd $_POST['y']."-".$_POST['x']."-".$_POST['z'];    
                    
    $tdName = ($y+1)."-".$x."-".$z;
                    if(
    $coOrd==$tdName)
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"2px\" height=\"2px\" style=\"padding:0; margin:0; background-color:black\" cellpadding=\"0\"></td>\n";
                        
                    }
                    else
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";
                    }
                }
                else
                {
                    echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";    
                }
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>\n";
    }

    ?>
    <div class="clear"></div>
    </div>
    <form action="1.php" method="post">
    <p>y - (box 1 - 16) <input type="text" name="y" /></p>
    <p>X - <input type="text" name="x" /></p>
    <p>Z - <input type="text" name="z" /></p>
    <input type="submit" name="submit" />
    </form>
    </body>
    </html>

  • #12
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    getting better:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ACT Web Designs - Home</title>
    <style type="text/css">
        * {
            padding:0;
            margin:0;
        }
        div.clear {
            clear:both;
        }
        #wrapper {
            width:900px;
            margin:30px;
        }
        div.wrapper2 {
            width:200px;
            height:200px;
            border:1px solid #000;
            float:left;
            position:relative;
        }
        div.boxNum {
            position:absolute;
            top:-10px;
            left:-10px;
        }
        table.table {
            margin:5px;    
        }
    </style>
    </head>
    <body>
    <div id="wrapper">
    <?php

    $colors16 
    = array("red""blue""green""orange""brown""black""white""pink""purple""yellow""green""red""orange""brown""pink""purple""yellow");

    for(
    $y 0$y <= 15$y++)
    {
        echo 
    "<div class=\"wrapper2\">\n";
        echo 
    "<div class=\"boxNum\">".($y+1)."</div>\n";
        echo 
    "<table class=\"table\" name=\"start_".($y*62)." style=\"padding:0; margin:0\" cellpadding=\"0\">\n";
        for(
    $x 1$x <= 62$x++)
        {
            echo 
    "<tr cellpadding=\"0\" style=\"padding:0; margin:0; \">";
            for(
    $z 1$z <= 62$z++)
            {
                if(isset(
    $_POST['x']))
                {
                    
    $coOrd $_POST['y']."-".$_POST['x']."-".$_POST['z'];    
                    
    $tdName = ($y+1)."-".$x."-".$z;
                    if(
    $coOrd==$tdName)
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"2px\" height=\"2px\" style=\"padding:0; margin:0; background-color:black\" cellpadding=\"0\"></td>\n";
                        
                    }
                    else
                    {
                        echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";
                    }
                }
                else
                {
                    echo 
    "<td name=\"".$y."-".$x."-".$z."\" width=\"1px\" height=\"1px\" style=\"padding:0; margin:0; background-color:".$colors16[$y]."\" cellpadding=\"0\"></td>\n";    
                }
            }
            echo 
    "</tr>";
        }
        echo 
    "</table>\n";
        echo 
    "</div>\n";
    }

    ?>
    <div class="clear"></div>
    </div>
    <form action="1.php" method="post">
    <p>y - (box 1 - 16) <input type="text" name="y" /></p>
    <p>X - <input type="text" name="x" /></p>
    <p>Z - <input type="text" name="z" /></p>
    <input type="submit" name="submit" />
    </form>
    </body>
    </html>

  • #13
    New Coder
    Join Date
    Feb 2009
    Location
    Mosjøen, Norway
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Getting really good now, Phil!

    Now all that's missing is breaking all of the 16 regions into links for example, and by using an ID or something be able to determine the max Y/X coordinates.

    For example taking Region 1:
    X coordinates: 0,0 - 124,0
    Y coordinates: 0,0 - 0,124

    Though I don't understand how to get those cross-lined from 0,0 to 124,124 or if it's possible.

    Loading field and coordinate information from a database and administering it on the visual map. Could possibly have a huge grid with the records showing up in a color within the square, maybe increasing the size from 1x1 pixels to 2x2 or something to see better.

  • #14
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    i will talk more in the morning (time for bed the missus says) but i was thinking more along the lines of hovering over a co-ord and displaying the infor at the side or something you need to keep the grtad as small as you can for loading times. I will work more on it in the mornig. If you could send me a mysql_dump for the structure of the table used for this is would be much easyer. Cya soon

  • #15
    New Coder
    Join Date
    Feb 2009
    Location
    Mosjøen, Norway
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Goodnight, Phil! Looking forward to work more with you tomorrow!

    Here's the MySQL dump as you requested by the way!
    Code:
    -- phpMyAdmin SQL Dump
    -- version 3.2.0.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Aug 28, 2009 at 01:56 
    -- Server version: 5.1.37
    -- PHP Version: 5.3.0
    
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    --
    -- Database: `evonymap`
    --
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `map_locations`
    --
    
    CREATE TABLE IF NOT EXISTS `map_locations` (
      `player_name` varchar(25) NULL,
      `flat_level` smallint(2) NULL,
      `flat_name` varchar(25) NOT NULL,
      `x_coordinate` smallint(3) NOT NULL,
      `y_coordinate` smallint(3) NOT NULL,
      `id` smallint(5) NOT NULL,
      `updated` smallint(10) NOT NULL,
      UNIQUE KEY `Map ID` (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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