[ka-Map-users] Overlay image

jochen at IngenieurTeam2.com jochen at IngenieurTeam2.com
Thu Sep 29 11:43:24 EDT 2005


Hello ka-map user,

I want to highlight polygons on the map (based on a query).
To do this (and perhaps other things) I want to render an image
with the size of the viewport which contains the visible part of the map.
And then overlay this image over the viewport.
This works as I suppose but I have problem with the scale.
It seems like there is a fractor missing. But which?

Best regards,
Jochen


//overlay.js start
function jg (oKaMap)
{
 this.kaMap = oKaMap;
 this.highlight = jg_highlight;
 this.drawOverlay = jg_drawOverlay;
}
    
function jg_highlight()
{
 var px = this.kaMap.getGeoExtents();
 var url = this.kaMap.server + "/overlay.php";
 url += "?map=" + this.kaMap.currentMap;
 url += "&width=" + this.kaMap.viewportWidth;
 url += "&height=" + this.kaMap.viewportHeight;
 url += "&minx=" + px[0];
 url += "&miny=" + px[1];
 url += "&maxx=" + px[2];
 url += "&maxy=" + px[3];
 call(url, this, this.drawOverlay);
}

function jg_drawOverlay (szResult)
{
 eval( szResult );
 var canvas = myKaMap.createDrawingCanvas( 500 );
 var img = document.createElement( 'img' ); 
 img.src = this.imgSrc; 
 img.style.width = this.kaMap.viewportWidth + "px";
 img.style.height = this.kaMap.viewportHeight + "px";
 this.kaMap.addObjectGeo(canvas, this.imgX, this.imgY, img );
}
//overlay.js start

//overlay.php start
<?php
 dl('php_mapscript_46.dll'); 
 
 $width  = $_REQUEST['width'];
 $height = $_REQUEST['height'];
 $minx = $_REQUEST['minx'];
 $miny = $_REQUEST['miny'];
 $maxx = $_REQUEST['maxx'];
 $maxy = $_REQUEST['maxy'];
 
 $map = ms_newMapObj("c:/path/file.map"); // the same mapfile like ka-map
shows
 $map->outputformat->set("transparent", MS_ON ); 
 $l1 = $map->getLayerByName ("L1");
 $l1 -> set("status", MS_OFF);        
 $l2 = $map->getLayerByName ("L2");
 $l2 -> set("status", MS_OFF);
 $l3 = $map->getLayerByName ("L3");
 $c3 = $l3 -> getClass (0);
 $style = ms_newStyleObj($c3); 
 $style->color->setRGB(255,0,0); // simulate highlighting 
 $map -> setExtent ($minx, $miny, $maxx, $maxy);
 $map -> setSize   ($width, $height);
 $image=$map->draw();
 $image_url=$image->saveWebImage();
 $szResult = "this.imgSrc = '".$image_url."';";
 $szResult .= "this.imgX = ".$minx.";";
 $szResult .= "this.imgY = ".$maxy.";";
 echo $szResult;
?>
//overlay.php end


More information about the ka-Map-users mailing list