[ka-Map-users] Showing a map twice on one page

Paul Spencer pspencer at dmsolutions.ca
Mon Nov 13 18:47:20 EST 2006


Ravi,

I've put two ka-Map's on the same page using iframes but I haven't  
tried it in the same page yet.  It should be possible, but I have  
doubts about the code being clean enough in its use of global variables.

If you can load at least one of the maps through an iframe, then you  
can trap extent events on one and use it to programmatically modify  
the extents of the other.

To write code that communicates with an iframe, you need something like:

document.getElementById('frame1').contentWindow

Anything you have in the iframe is separate, but you can communicate  
with it.  For instance:

myKaMap.registerForEvent( KAMAP_EXTENTS_CHANGED, null, synchronize );

function synchronize() {
   var extents = myKaMap.getGeoExtents();
   var cx = (extents[2] + extents[0])/2;
   var cy = (extents[3] + extents[1])/2;
   var scale = myKaMap.getCurrentScale();
   var iframeMap = document.getElementById 
('frame1').contentWindow.myKaMap;
   iframeMap.zoomTo(cx,cy,scale);
}

Cheers

Paul

On 13-Nov-06, at 5:18 PM, Ravi wrote:

>
> Hello everybody,
>
> I have a strange requirement. I need to show the same map twice  
> with different layers turned on/off.
>
> So essentially, there will be one large map on right side as  
> default and one map on the left sidebar in a smaller size. I want  
> to be able to switch the layers independently but I want the  
> panning/zoomimg to be tied together.
>
> Any pointers what is the best way to achieve this?
>
> Thanks
> Ravi
>
>
>
>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+






More information about the ka-Map-users mailing list