Rasters, TileIndex and Shapefiles - Oh My! Now markers won't display tran

Christopher Harris docterrobert at MSN.COM
Wed Oct 3 17:12:50 EDT 2007


Nope.  I know about that.  I'm using Firefox.  I know IE7 can handle .png's.  I hate IE6 - especially when I'm compensating for that crap browser when I'm using CSS.

From: williams at websawyer.com
Subject: Re: [UMN_MAPSERVER-USERS] Rasters, TileIndex and Shapefiles - Oh My!  Now markers won't display tran
Date: Tue, 2 Oct 2007 08:52:12 -0600
To: docterrobert at MSN.COM

IE6 will not show a transparent png as transparent, only a transparent gif.  Could be a browser problem!
On Oct 1, 2007, at 10:39 AM, Christopher Harris wrote:(Problem described on second parapraph.)Alrighty...........it works!  What's most exciting is that the problem that I eluded to in my last reply (the markers or points being off a few hundred yards in a circular pattern) has been fixed as a result of all your advice from earlier.  I don't know if it was from me using a shapefile to describe the tile index or if it was from me adjusting lines 1 & 4 in the world file to correctly define the x and y map unit/pixel ratio.  I'll play around with it and figure it out.  I got it working last Friday right before I left work.  Thanks a million!Now - one minor issue.  The markers that I'm placing all display and show up at the right spots, but they aren't displaying there transparent backgrounds.  I'm using .png's, and always there's a black background being displayed.  I've double checked in The GIMP and there's definitely no background.  I noticed on the Mapscript API in the "Layers" class that there's a member called transparency and that it takes an int value.  I know that a lot of the members that say int actually take a constant as defined in the constants section, but none of them work (MS_ON, MS_TRUE, MS_YES, MS_GD_ALPHA) and actual integers like -10 through 10 don't work either.  I know the layer's type shouldn't be set to Raster.  Here's the code snippets and sections where I define my marker and the layer it is on://Location Marker Layer///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$markerLayer = ms_newLayerObj($map);$markerLayer->set(name, "Marker");$markerLayer->set(type, MS_LAYER_POINT);$markerLayer->set(status, MS_DEFAULT);//Location Marker layer class$markerclass = ms_newClassObj($markerLayer);//Location Marker layer class style$markerstyle = ms_newStyleObj($markerclass);//Sets the size of the marker.  The bigger, the badder.......$markerstyle->set(size, 15);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////and$layer=$map->getLayerByName("Marker");$layer->status = MS_DEFAULT;//Loop creates marker points then populates them on the mapfor($i=0; $i<$markerCount; $i++){    //Creates a point so the marker can be drawn    $marker[$i] = ms_newPointObj();    //Sets that marker according to respective x,y's    $marker[$i]->setXY($mx[$i], $my[$i]);    //Gives the location of the symbol to place as a marker    $markerstyle->set(symbolname, "data/statesp020/$mi[$i]");    //Draws the point using the map, layer Marker, and the image generated, and the only class it has (Index 0)    $marker[$i]->draw($map, $layer, $image, 0, "");}Here's the rest of my php (with the code above in it):<?php//Takes the $_GET array's and keys and sets them to another array $keys = array_keys($_GET);//This loop will find all values that have a name lat, lon, and mi (marker icon) and set them to their own arrayforeach($keys as $curvar){    if((substr($curvar, 0, 3))=="lat"){        $my[] = $_GET[$curvar];    }    if((substr($curvar, 0, 3))=="lon"){        $mx[] = $_GET[$curvar];    }    if((substr($curvar, 0, 2))=="mi"){        $mi[] = $_GET[$curvar];    }}//The count of how many points were entered in$markerCount = count($mx);//echo "<br>The marker count is: $markerCount<br>";//Map pic width, height parameters//////////////////////////////////////////////////////////////////////////$mapwidth = $_GET['width'];$mapheight = $_GET['height'];//New point object for Zooming$centerpoint = ms_newPointObj();//Taking the center points of the image$centerX = $mapwidth/2;$centerY = $mapheight/2;$centerpoint->setXY($centerX, $centerY);////////////////////////////////////////////////////////////////////////////The zoompoint and zoomscale parameters////////////////////////////////////////////////////////////////////////////$zoompoint = $_GET['zoompoint'];    ZOOMPOINT ZOOMS IN ON A PIXEL$zoomscale = $_GET['zoomscale'];////////////////////////////////////////////////////////////////////////////Center Coordinates passed will be in decimal degrees//////////////////////////////////////////////////////////////////////////$x = $_GET['lon1'];$y = $_GET['lat1'];//Create a new recObj with dd extents$extent = ms_newRectObj();//Set those extents$extent->setextent($x-.002, $y-.002, $x+.002, $y+.002);//Set the newly adjusted extent variables$x1 = $extent->minx;$y1 = $extent->miny;$x2 = $extent->maxx;$y2 = $extent->maxy;//Upper left and lower right coordinates//$ULx = $x1;//$ULy = $y2;//$LRx = $x2;//$LRy = $y1;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////The Map Itself/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////The mapfile path and map file itself$map_path = "/var/www/mapserver/campuscomber/";$map_file = "indexAlt.map";$map = ms_newMapObj($map_path.$map_file);//The size of the window set by mapserver$map->setSize($mapwidth, $mapheight);//The name of the map$map->set(name, "US Universities");$app = $_GET['app'];//The type of image produced depending if request comes from Wap, Kiwi, or Webcomberif($app=="app"){    $map->selectOutputFormat("GIF");    //Sets the output format type    $map->outputformat->setOption(name, "gif");    $map->outputformat->setOption(driver, "GD/GIF");    $map->outputformat->setOption(mimetype, "image/gif");    $map->outputformat->setOption(imagemode, MS_IMAGEMODE_RGB);    $map->outputformat->setOption(extension, "gif");}if($app=="kiwi" || $app=="web"){    $map->selectOutputFormat("PNG");    //Sets the output format type    $map->outputformat->setOption(name, "png");    $map->outputformat->setOption(driver, "GD/PNG");    $map->outputformat->setOption(mimetype, "image/png");    $map->outputformat->setOption(imagemode, MS_IMAGEMODE_PC256);    $map->outputformat->setOption(extension, "png");}//The color of the background$map->imagecolor->setRGB(140, 140, 140);//Tells where the US Shapefile info and images are located$map->set(shapepath, "/var/www/mapserver/campuscomber/data/statesp020/");//Sets the map projection lat/lon$map->setProjection("+proj=latlong +ellps=GRS80 +datum=NAD83");//sets the EXTENT$map->setExtent($x1, $y1, $x2, $y2);$map->set(units, MS_DD);$map->set(debug, MS_ON);//Web Object which specifies the image path and the image url for the image Maperver generates$map->web->set(imagepath, "/var/www/mapserver/campuscomber/images/");$map->web->set(imageurl, "/mapserver/campuscomber/images/");/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////United States layer///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$us = ms_newLayerObj($map);$us->set(name, "US state polygons");$us->set(type, MS_LAYER_POLYGON);$us->set(status, MS_DEFAULT);$us->set(data, "statesp020");//United States layer class$usclass = ms_newClassObj($us);//United States layer class style$usstyle = ms_newStyleObj($usclass);$usstyle->color->setRGB(240, 230, 140);$usstyle->set(symbol, 0);/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////US Boundaries Layer///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$usbounds = ms_newLayerObj($map);$usbounds->set(name, "US state boundaries");$usbounds->set(type, MS_LAYER_LINE);$usbounds->set(status, MS_DEFAULT);$usbounds->set(data, "statesp020");//US Boundaries layer class$usboundsclass = ms_newClassObj($usbounds);//US Boundaries layer class style$usboundsstyle = ms_newStyleObj($usboundsclass);$usboundsstyle->color->setRGB(50, 50, 50);$usboundsstyle->set(size, 3);$usboundsstyle->set(symbol, 0);$usboundsstyle->set(symbol, 0);/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////University Map Layer (Actually, I don't think we even need this layer - but ehhh, who knows?)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$university = ms_newLayerObj($map);$university->set(name, "University of Illinois");$university->set(type, MS_LAYER_RASTER);$university->set(status, MS_OFF);$university->set(data, "UofICampusMapAlt.gif");/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Tiled University Map Layer///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$universityTiles = ms_newLayerObj($map);$universityTiles->set(name, "University of Illinois Tiles");$universityTiles->set(type, MS_LAYER_RASTER);$universityTiles->set(status, MS_DEFAULT);$universityTiles->set(tileindex, "u_of_ill.shp");$universityTiles->set(tileitem, "Location");/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Location Marker Layer///////////////////////////////////////////////////////////////////////////////////////////////////////////////////$markerLayer = ms_newLayerObj($map);$markerLayer->set(name, "Marker");$markerLayer->set(type, MS_LAYER_POINT);$markerLayer->set(status, MS_DEFAULT);//Location Marker layer class$markerclass = ms_newClassObj($markerLayer);//Location Marker layer class style$markerstyle = ms_newStyleObj($markerclass);//Sets the size of the marker.  The bigger, the badder.......$markerstyle->set(size, 15);/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////$map->zoompoint(1, $centerpoint, $mapwidth, $mapheight, $extent);//Sets the zoom scale for zooming in and out$map->zoomscale($zoomscale, $centerpoint, $mapwidth, $mapheight, $extent);//Draws the image$image=$map->draw();//Gets the Marker Layer$layer=$map->getLayerByName("Marker");$layer->status = MS_DEFAULT;//Loop creates marker points then populates them on the mapfor($i=0; $i<$markerCount; $i++){    //Creates a point so the marker can be drawn    $marker[$i] = ms_newPointObj();    //Sets that marker according to respective x,y's    $marker[$i]->setXY($mx[$i], $my[$i]);    //Gives the location of the symbol to place as a marker    $markerstyle->set(symbolname, "data/statesp020/$mi[$i]");    //Draws the point using the map, layer Marker, and the image generated, and the only class it has (Index 0)    $marker[$i]->draw($map, $layer, $image, 0, "");}//Produces a url to reference the image by$image_url=$image->saveWebImage();echo $image_url."<br>";?><html>    <head>        <title>Mapserver "University of Illinois"</title>    </head>    <body>        <img src="<?php echo $image_url?>">    </body></html>Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

_________________________________________________________________
Peek-a-boo FREE Tricks & Treats for You!
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20071003/089bcfe6/attachment.html


More information about the mapserver-users mailing list