Hub You
#1 in Business Subscribe Email Print

You are here: Home > Internet and Businesses Online > Web Development > How to Draw Icons or Images on a Mapserver Generated Map

Tags

  • small
  • connect
  • mapscaleimagecopy mapimg
  • small enougth
  • image generated

  • Links

  • The Entrepreneur Cheerleading Section - The 5:15 Report
  • Enjoying The Log Home Lifestyle
  • Facial rejuvenation, including facelift, browlift, and laser surgery
  • Hub You - How to Draw Icons or Images on a Mapserver Generated Map

    Email Marketing - Why Should People Read Your Emails?
    Why SHOULD people read your emails? I think that sometimes people set up these lists, add in a bunch of emails, send people to a squeeze page, give them a gift, then wonder why their emails don’t get read or opened.Look, I get around 100 emails per day just from people whose lists I am on. That is not counting 300+ spasm per day and 200 emails from my web system. So out of 100 emails that I get daily from someone’s list, how many do I open? Maybe 5. So I account for a 5% open rate. If everyone one your list gets 100 emails a day, then if
    >maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapim

    Employee Rewards Reap Results
    The way you reward people forms an essential foundation for effective people management. Money is by no means the only motivator of people, but too little money demotivates powerfully. Studies have shown that material reward is far more powerful than monetary.1. How To Determine Levels Of RewardTo determine how much reward is appropriate, consider the question what level of employee reward will attract, retain, and motivate people of the calibre that you require. If an employee does something that results in a one-time boost for the comp
    In this example I have used the map of the Itasca demo of the Mapserver. I have done only small changes to the map file. The Itasca demo has (into the html file) the parameters of the path where to store the images:

    IMAGEPATH "set in index.html" IMAGEURL "set in index.html"

    I have changed them as fixed path

    IMAGEPATH "/tmp/ms_tmp/" IMAGEURL "/ms_tmp/"

    Than I have set as STATUS ON several layers for a better map.

    The Database

    The positions and the images paths that have to be shown on the map are stored into a table of a database in MySql. I have created a new database named "mapexample" and a new table "weather":

    CREATE TABLE weather (

    id bigint(20) NOT NULL auto_increment,

    imagepath varchar(255) default NULL,

    x double(16,4) default NULL,

    y double(16,4) default NULL,

    PRIMARY KEY (id)

    )

    and than I have inserted into the table the positions of the weather images and the path of every icon:

    INSERT INTO `weather` VALUES (1, '/data/weather/icons/sunny.gif', 478107.0000, 5250301.0000); INSERT INTO `weather` VALUES (2, ''/data/weather/icons/cloudy.gif', 408107.0000, 5220301.0000); INSERT INTO `weather` VALUES (3, ''/data/weather/icons/storm.gif', 468107.0000, 5270301.0000); INSERT INTO `weather` VALUES (4, ''/data/weather/icons/variable.gif', 408107.0000, 5310301.0000);

    It is not necessary for the images to be stored into a directory visible from the web, because are taken directly by the script and then merged with the map.

    The PHPMapscript code Here is the code I have used for generating the map:

    define("img_WIDTH", 0); define("img_HEIGHT", 1); define("img_TYPE", 2);

    // CONFIGURATION OF MYSQL ACCESS $MyHost = "localhost"; $MyLogin = "root"; $MyPassword = ""; $MyDatabase = "mapexample";

    $mappath = "D:/data/web"; $scale_to_showicons = 1000000; // SCALE LIMIT TO START TO SHOW THE ICONS ON THE MAP

    function AddImagesToMap($mapurl) {

    global $MyHost, $MyLogin, $MyPassword, $MyDatabase, $scale_to_showicons, $map, $mappath;

    // CONNECT TO DATABASE

    @mysql_connect($MyHost, $MyLogin, $MyPassword);

    @mysql_select_db($MyDatabase);

    // IF the scale is small enougth to show the images on the map?

    if ($scale_to_showicons > $map->scale) {

    // PATH WHERE TO FIND THE MAP IMAGE GENERATED BY MAPSERVER

    $mapimagepath = $mappath . $mapurl;

    $mapdim = GetImageSize($mapimagepath);

    $coords_map_width = $map->extent->maxx - $map->extent->minx;

    $mapscale = $mapdim[img_WIDTH] / $coords_map_width;

    switch ($mapdim[img_TYPE]) {

    case 1:

    $mapimg = ImageCreateFromGif($mapimagepath);

    break;

    case 2:

    $mapimg = ImageCreateFromJpeg($mapimagepath);

    break;

    case 3:

    $mapimg = ImageCreateFromPng($mapimagepath);

    break;

    } ;

    $qry .= "select * from weather where x > '" . $map->extent->minx . "' AND x < '" . $map->extent->maxx . "'

    AND y > '" . $map->extent->miny . "' AND y < '" . $map->extent->maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapima

    How To Build and Maximize the Power of Your Database
    If you have read any of my previous articles, you know that I am a big advocate of database management. The purpose of this article is to dig deeper into the nuts and bolts of how to build, develop, and maximize your database with the goal of increasing your profits.Many business people do not even have a database, and those that do many times do not consider it anything more than an electronic rolodex designed to keep track of phone numbers and email addresses. I can tell you from personal experience that a database, if properly cultivated,
    NULL,

    x double(16,4) default NULL,

    y double(16,4) default NULL,

    PRIMARY KEY (id)

    )

    and than I have inserted into the table the positions of the weather images and the path of every icon:

    INSERT INTO `weather` VALUES (1, '/data/weather/icons/sunny.gif', 478107.0000, 5250301.0000); INSERT INTO `weather` VALUES (2, ''/data/weather/icons/cloudy.gif', 408107.0000, 5220301.0000); INSERT INTO `weather` VALUES (3, ''/data/weather/icons/storm.gif', 468107.0000, 5270301.0000); INSERT INTO `weather` VALUES (4, ''/data/weather/icons/variable.gif', 408107.0000, 5310301.0000);

    It is not necessary for the images to be stored into a directory visible from the web, because are taken directly by the script and then merged with the map.

    The PHPMapscript code Here is the code I have used for generating the map:

    define("img_WIDTH", 0); define("img_HEIGHT", 1); define("img_TYPE", 2);

    // CONFIGURATION OF MYSQL ACCESS $MyHost = "localhost"; $MyLogin = "root"; $MyPassword = ""; $MyDatabase = "mapexample";

    $mappath = "D:/data/web"; $scale_to_showicons = 1000000; // SCALE LIMIT TO START TO SHOW THE ICONS ON THE MAP

    function AddImagesToMap($mapurl) {

    global $MyHost, $MyLogin, $MyPassword, $MyDatabase, $scale_to_showicons, $map, $mappath;

    // CONNECT TO DATABASE

    @mysql_connect($MyHost, $MyLogin, $MyPassword);

    @mysql_select_db($MyDatabase);

    // IF the scale is small enougth to show the images on the map?

    if ($scale_to_showicons > $map->scale) {

    // PATH WHERE TO FIND THE MAP IMAGE GENERATED BY MAPSERVER

    $mapimagepath = $mappath . $mapurl;

    $mapdim = GetImageSize($mapimagepath);

    $coords_map_width = $map->extent->maxx - $map->extent->minx;

    $mapscale = $mapdim[img_WIDTH] / $coords_map_width;

    switch ($mapdim[img_TYPE]) {

    case 1:

    $mapimg = ImageCreateFromGif($mapimagepath);

    break;

    case 2:

    $mapimg = ImageCreateFromJpeg($mapimagepath);

    break;

    case 3:

    $mapimg = ImageCreateFromPng($mapimagepath);

    break;

    } ;

    $qry .= "select * from weather where x > '" . $map->extent->minx . "' AND x < '" . $map->extent->maxx . "'

    AND y > '" . $map->extent->miny . "' AND y < '" . $map->extent->maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapim

    SEO and Creating IBLs (One way inbound links) to Your Website
    Building up the number of links into your own site is essential for SEO because search engines count the number of inward links that you have. Yahoo and Google analyse these links differently, with Google generally being far more specific about which links they accept. A search for one phrase I searched for, for example, returned 63 links with Google, yet 3250 with Yahoo.'Page-rank' is Google's grading of your website, measured via a combination of factors including the number of inward links, the keyword density of your page, how often your pa
    b>The PHPMapscript code Here is the code I have used for generating the map:

    define("img_WIDTH", 0); define("img_HEIGHT", 1); define("img_TYPE", 2);

    // CONFIGURATION OF MYSQL ACCESS $MyHost = "localhost"; $MyLogin = "root"; $MyPassword = ""; $MyDatabase = "mapexample";

    $mappath = "D:/data/web"; $scale_to_showicons = 1000000; // SCALE LIMIT TO START TO SHOW THE ICONS ON THE MAP

    function AddImagesToMap($mapurl) {

    global $MyHost, $MyLogin, $MyPassword, $MyDatabase, $scale_to_showicons, $map, $mappath;

    // CONNECT TO DATABASE

    @mysql_connect($MyHost, $MyLogin, $MyPassword);

    @mysql_select_db($MyDatabase);

    // IF the scale is small enougth to show the images on the map?

    if ($scale_to_showicons > $map->scale) {

    // PATH WHERE TO FIND THE MAP IMAGE GENERATED BY MAPSERVER

    $mapimagepath = $mappath . $mapurl;

    $mapdim = GetImageSize($mapimagepath);

    $coords_map_width = $map->extent->maxx - $map->extent->minx;

    $mapscale = $mapdim[img_WIDTH] / $coords_map_width;

    switch ($mapdim[img_TYPE]) {

    case 1:

    $mapimg = ImageCreateFromGif($mapimagepath);

    break;

    case 2:

    $mapimg = ImageCreateFromJpeg($mapimagepath);

    break;

    case 3:

    $mapimg = ImageCreateFromPng($mapimagepath);

    break;

    } ;

    $qry .= "select * from weather where x > '" . $map->extent->minx . "' AND x < '" . $map->extent->maxx . "'

    AND y > '" . $map->extent->miny . "' AND y < '" . $map->extent->maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapim

    Tips to Protect Your Downloads or Products
    1. Upload robots.txt file in to your root directory and include the folder name where you set your downloads.More information on how to set robots.txt: http://www.webmasters-central.com/wp/se/robotstxt.shtml2. Set the permission of the download folder to 711 OR upload an index file to that folder. This makes that folder web inaccessible.For example create a folder named 'test'. Usually by default it will be chmoded to 755 or 777. Put some files lik
    >if ($scale_to_showicons > $map->scale) {

    // PATH WHERE TO FIND THE MAP IMAGE GENERATED BY MAPSERVER

    $mapimagepath = $mappath . $mapurl;

    $mapdim = GetImageSize($mapimagepath);

    $coords_map_width = $map->extent->maxx - $map->extent->minx;

    $mapscale = $mapdim[img_WIDTH] / $coords_map_width;

    switch ($mapdim[img_TYPE]) {

    case 1:

    $mapimg = ImageCreateFromGif($mapimagepath);

    break;

    case 2:

    $mapimg = ImageCreateFromJpeg($mapimagepath);

    break;

    case 3:

    $mapimg = ImageCreateFromPng($mapimagepath);

    break;

    } ;

    $qry .= "select * from weather where x > '" . $map->extent->minx . "' AND x < '" . $map->extent->maxx . "'

    AND y > '" . $map->extent->miny . "' AND y < '" . $map->extent->maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapim

    How SMB Exporters Can Build and Strengthen Relationships With Overseas Partners
    It is easy for exporting SMBs to establish, build and maintain flourishing relationships with their overseas partners, be they customers, representatives, or distributors.It is all a matter of communicating on an ongoing basis. The Translation Service Provider is the cornerstone of your communication strategy which will go a long way towards earning you long-term goodwill from your overseas partners.As you are well aware, a foreign contact should be treated and served exactly in the same way as a domestic contact. For example, customers
    >maxy . "'";

    $res = mysql_query($qry);

    while ($row = mysql_fetch_object($res)) {

    $dimic = GetImageSize($row->imagepath);

    switch ($dimic[img_TYPE]) {

    case 1:

    $tmpimg = ImageCreateFromGif($row->imagepath);

    break;

    case 2:

    $tmpimg =?; ImageCreateFromJpeg($row->imagepath);

    break;

    case 3:

    $tmpimg = ImageCreateFromPng($row->imagepath);

    break;

    }

    $x = ($row->x - $map->extent->minx) * $mapscale;

    $y = $mapdim[img_HEIGHT] - (($row->y - $map->extent->miny) * $mapscale);

    @ImageCopy ($mapimg, $tmpimg, $x, $y, 0, 0, $dimic[img_WIDTH], $dimic[img_HEIGHT]);

    } ;

    // SAVE THE NEW IMAGE ON THE OLD ONE

    switch ($mapdim[img_TYPE]) {

    case 1:

    ImageGif($mapimg, $mapimagepath);

    break;

    case 2:

    ImageJpeg($mapimg, $mapimagepath);

    break;

    case 3:

    ImagePng($mapimg, $mapimagepath);

    break;

    }

    } ; } ;

    $map = ms_newMapObj("itasca.map");

    $img = $map->draw(); $url = $img->saveWebImage(); AddImagesToMap($url);

    ?>

    Show Weather On Map

    More info: http://www.parsec.it/tutorials/

    HTTP = HTML link (for blogs, profiles,phorums):
    <a href="http://www.iadvice.info/article/87410/iadvice-How-to-Draw-Icons-or-Images-on-a-Mapserver-Generated-Map.html">How to Draw Icons or Images on a Mapserver Generated Map</a>

    BB link (for phorums):
    [url=http://www.iadvice.info/article/87410/iadvice-How-to-Draw-Icons-or-Images-on-a-Mapserver-Generated-Map.html]How to Draw Icons or Images on a Mapserver Generated Map[/url]

    Related Articles:

    7 Bits Of Critical Information You Can't Afford NOT To Know About Your Customers

    Marketing Your Business: Make Your Promotional Tools Work Smarter

    Free Email Marketing Tips - 3 Free Email Marketing Tips

    Bookmark it: del.icio.us digg.com reddit.com netvouz.com google.com yahoo.com technorati.com furl.net bloglines.com socialdust.com ma.gnolia.com newsvine.com slashdot.org simpy.com shadows.com blinklist.com