FW: [ka-Map-users] Overlay image
jochen at IngenieurTeam2.com
jochen at IngenieurTeam2.com
Tue Oct 4 09:16:07 EDT 2005
Hello Brent,
this is unfortunately not the problem, my problem is that the scale of
ka-map don't matches the scale of my image. Besides that the redrawfunction
has to be called whenever the extent of ka-map changes, even if you're
panning.
Thanks,
jochen
________________________________
From: Brent Pedersen [mailto:bpederse at gmail.com]
Sent: Donnerstag, 29. September 2005 18:36
To: Grefe, Jochen
Cc: ka-map-users at lists.maptools.org
Subject: Re: [ka-Map-users] Overlay image
hi, if i understand correctly
if you overlay your own image, it is static and you must do
myKaMap.registerForEvent(KAMAP_SCALE_CHANGED,this,redrawFunction)
in order to get a new image on zoom in/out. where redrawFunction has to
remove current image, and resend the request for a new image given the new
extents
-brent
On 9/29/05, jochen at ingenieurteam2.com <jochen at ingenieurteam2.com > wrote:
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
_______________________________________________
ka-Map-users mailing list
ka-Map-users at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/ka-map-users
More information about the ka-Map-users
mailing list