How to attract icons or photographs on the map server

On this instance I’ve used the map of Itasca presentation on the map server. I’ve made solely minor adjustments to the cardboard file. The Itasca demo has (in html file) the parameters of the URL the place to retailer the images:

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

I’ve change them as a set path

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

However I've put as a STANDARD on a number of layers for higher maps.

Database

The positions and pictures that seem on the map are saved within the MySql database desk.
Create a brand new database referred to as "mapexample" and a brand new desk "climate":

CREATE TABLE climate (id bigint (20) NOT NULL auto_increment, imagepath varchar (255) default NULL, x binary (16.four) default NULL, y double (16.four) default NULL, PRIMARY KEY (id))

and however I’ve inserted the desk with climate circumstances and the way in which in all icons:

BAT IN `WEATHER` VALUES (1, & # 39; /knowledge/climate/icons/sunny.gif'; 478107.0000; 5250301.0000); INTRODUCTION to "climate" worth (2, & # 39; knowledge /climate/icons/cloudy.gif & # 39 ;, 408107.0000, 5220301.0000); INTRODUCTION to "climate" worth (three, & # 39; /knowledge/climate/icons/storm.gif & 46; 468107.0000, 5270301.0000); INTRODUCTION to "climate" worth (four, & # 39; /knowledge/climate/icons/variable.gif, 408107.0000, 5310301.0000);

It isn’t essential to retailer the pictures in a folder seen from the net as a result of they had been taken instantly from the script after which merged with the map.

PHPMapscript Quantity

Right here is the code that I used to create the map:

&lt;? php dl (&quot;php_mapscript.dll&quot;); outline (&quot;img_WIDTH&quot;, zero); outline (&quot;img_HEIGHT&quot;, 1); outline (&quot;img_TYPE&quot;, 2); // CONFIGURATION MYSQL ACCESS $ MyHost = &quot;localhost&quot;; $ MyLogin = &quot;root&quot;; $ MyPassword = &quot;&quot;; $ MyDatabase = &quot;folderexample&quot;; $ mappath = &quot;D: / knowledge / internet&quot;; // CONDITIONS LIMIT TO START TO SHOW YOURS ON THE MAP $ scale_to_showicons = 1000000; perform AddImagesToMap ($ mapurl) world $ MyHost, $ MyLogin, $ MyPassword, $ MyDatabase; International $ scale_to_showicons, $ map, $ mappath; // Hyperlink to database @ mysql_connect ($ MyHost, $ MyLogin, $ MyPassword); @mysql_select_db ($ MyDatabase); // IF scale is small enougth to point out the pictures on the map? if ($ scale_to_showicons&gt; $ map-&gt; scale) // PATH WHAT TO FIND THE MAP PICTURE MORE BY MAPSERVER $ mapimagepath = $ mappath. $ mapurl; $ mapdim = GetImageSize ($ mapimagepath); $ coords_map_width = $ folder-&gt; expand-&gt; maxx &#8211; $ map-&gt; amount-&gt; minx; $ mapscale = $ mapdim [img_WIDTH] / $ coords_map_width; swap ($ mapdim [img_TYPE]) case 1: $ mapimg = ImageCreateFromGif ($ mapimagepath); break; Case 2: $ mapimg = ImageCreateFromJpeg ($ mapimagepath); break; Case three: $ mapimg = ImageCreateFromPng ($ mapimagepath); break; ; $ qry. = &quot;choose * from climate the place x&gt; &amp; # 39;&quot;. $ card-&gt; size-&gt; minx. &quot;&amp; # 39; AND x length-&gt; maxx. &amp; # 39; AND y&gt; &amp; # 39;&quot;. $ Map-&gt; expand-&gt; miny. &quot;$ And y length-&gt; maxy.&quot; &quot;$ Res = mysql_query ($ qry); whereas ($ row = mysql_fetch_object ($ res)) $ dimic = GetImageSize ($ row-&gt; imagepath); Swap ($ dimic [img_TYPE]) case 1: $ tmpimg = ImageCreateFromGif ($ row-&gt; imagepath); fraction; case 2: $ tmpimg =?; ImageCreateFromJpeg; $ three = $ tmpimg = ImageCreateFromPng ($ row-&gt; imagepath); break; $ x = ($ row-&gt; x- $ card-&gt; extten-&gt; minx) * $ mapscale; $ y = $ mapdim [img_HEIGHT] &#8211; (($ row-&gt; y- $ map-&gt; extten-&gt; miny) * $ mapscale); @ImageCopy ($ mapimg, $ tmpimg, $ x, $ y, zero, zero, $ dimic [img_WIDTH] $ dimic [img_HEIGHT]; / SAVE NEW IMAGE ON OLD ONE CHANGE ($ mapdim [img_TYPE]) case 1: ImageGif ($ mapimg, $ mapimagepath); fraction; case 2: ImageJpeg ($ mapimg, $ mapimagepath); fraction; case three: ImagePng ($ mapimg, $ mapimagepath); fragments;;} ; $ map = ms_newMapObj (&quot;itasca.map&quot;); img = $ map-&gt; draw (); $ url = $ img-&gt; saveWebImage (); AddImagesToMap ($ url);?&gt; <title> Present Climate On choir ten </ title> &lt;img src = &quot;<? php% 20echo% 20% 24url;% 20?>&quot;&gt;

Additional Data: http://www.parsec.it/ course /

Supply by Roberto Colonello

Leave a Reply

Your email address will not be published. Required fields are marked *