[Chameleon] MapTips and JSAPI

Eijnden, B. van den (Bart) b.vdeijnden at agi.rws.minvenw.nl
Thu Apr 6 03:01:19 EDT 2006


Okay, gotten a little progress on this one.

I have written a litter wrapper script around the MapTips widget (based on
UpdateMap.php), called maptips.php.

Using the JSAPI event manager, I do an AJAX call to this script whenever the
map extent changes. For this I had to adapt the MapTips widget not to
include the <map> and </map> HTML tag when generating the ImageMap, since
the content is set using innerHTML. I'll suggest a fix for this in bugzilla,
i.e. the GenerateImageMap function should not add the <map> header but the
DrawPublish function should do that.

So basically in the HTML template:

1) at the onload, register the event:
goCWCJSAPI.RegisterEvent(MAP_EXTENT_CHANGED, "GetImageMap")

2) GetImageMap function does a AJAX call to maptips.php:
function GetImageMap()
{
  call('/chameleon/widgets/MapTips/maptips.php?sid=[$gszSessId$]&minx=' +
goCWCJSAPI.oMap.minx +
    '&miny='+goCWCJSAPI.oMap.miny + '&maxx=' + goCWCJSAPI.oMap.maxx +
    '&maxy='+goCWCJSAPI.oMap.maxy, null, processAjax);
}

3) when the browser receives the content from maptips.php, it will trigger
the processAjax function which sets the innerHTML (IE specific btw):
function processAjax(szResults)
{
  if (document.all)
    document.all.maptips_imagemap6.innerHTML= "'"+szResults+"'";
}

4) don't forget to add the imagemap to your HTML template:
<map name="maptips_imagemap6"></map>

The maptips.php wrapper script does the necessary processing to generate the
image map based on the MapTips widget, an excerpt is:

$oMap = $oMapSession->oMap;
$oMap->setExtent($_GET['minx'], $_GET['miny'], $_GET['maxx'],
$_GET['maxy']);
$_SESSION["gszCurrentState"] = $oMapSession->saveState();
include_once("MapTips.widget.php");
$oWidget = new MapTips();
$oWidget->maParams["LAYER"] = 'werkzaamheden';
$oWidget->maParams["ATTRIBUTES"] = 'WEGNUMMER,STT_NAAM,GME_NAAM';
$oWidget->maParams["ONMOUSEOVER"] = 'myMaptipsOver';
$oWidget->maParams["ONMOUSEOUT"] = 'myMaptipsOut';
$oWidget->maParams["VISIBLE"] = 'false';
$oWidget->InitDefaults();
$oWidget->SetMap($oMapSession);
echo $oWidget->GenerateImageMap();

This shows the advantages of using AJAX in combination with Chameleon JSAPI,
maybe not everybody knows but starting Chameleon 2.4 there is a small ajax
library in chameleon/htdocs/common/ajax/xhr.js which has the call javascript
function in it which I use in GetImageMap.

Best regards,
Bart

-----Oorspronkelijk bericht-----
Van: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org]Namens Eijnden, B. van den
(Bart)
Verzonden: woensdag 5 april 2006 13:13
Aan: 'chameleon at lists.maptools.org'
Onderwerp: [Chameleon] MapTips and JSAPI


Hi list,

did anyone ever attempt to adapt the MapTips widget to work in JSAPI mode?

Would this even be possible? I.e. can the current generation of browsers
handle an imagemap which is not embedded in the HTML page?

Best regards,
Bart


Disclaimer
************************************************************************
Aan dit bericht kunnen geen rechten worden ontleend. Dit bericht is
uitsluitend bestemd voor de geadresseerde. Als u dit bericht per abuis
hebt ontvangen, wordt u verzocht het te vernietigen en de afzender te 
informeren. Wij adviseren u om bij twijfel over de juistheid of de 
volledigheid van de mail contact met afzender op te nemen.

This message shall not constitute any rights or obligations.
This message is intended solely for the addressee.
If you have received this message in error, please delete it and
notify the sender immediately. When in doubt whether this message
is correct or complete, please contact the sender.
************************************************************************

_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon


Disclaimer
************************************************************************
Aan dit bericht kunnen geen rechten worden ontleend. Dit bericht is
uitsluitend bestemd voor de geadresseerde. Als u dit bericht per abuis
hebt ontvangen, wordt u verzocht het te vernietigen en de afzender te 
informeren. Wij adviseren u om bij twijfel over de juistheid of de 
volledigheid van de mail contact met afzender op te nemen.

This message shall not constitute any rights or obligations.
This message is intended solely for the addressee.
If you have received this message in error, please delete it and
notify the sender immediately. When in doubt whether this message
is correct or complete, please contact the sender.
************************************************************************



More information about the Chameleon mailing list