AW: [OpenLayers-Users] New Popup windows

Joel Leininger leiningr at gmail.com
Sun Jun 19 00:57:00 EDT 2011


Wow. This was just perfect. Thanks a million.

-J.

On Sat, 2011-06-18 at 14:21 +0200, Arnd Wippermann wrote:
> There is no function in OpenLayers to create a popup as a new window. You
> have to do it by yourself.
> 
> Below how it should work:
> 
> getfeatureinfo: function(event) 
> {
>     //PopupWindow(Links, Oben, dieBreite, dieHoehe, dieUrl, derInhalt,
> targetValue)
>     PopupWindow(100, 100, 300, 400, "", event.text, "_new")
> }
> 
> 
> //##########################################################################
> #################
> // popup window handling, close child windows
> //##########################################################################
> #################
> function PopupWindow(Links, Oben, dieBreite, dieHoehe, dieUrl, derInhalt,
> targetValue)
> {
>     // neues Fenster öffnen
> 
>     var szWinStyle = new String ("");
>     szWinStyle =  'toolbar=no, location=no, directories=no, status=yes,
> menubar=no, scrollbars=yes, resizable=yes';
>     szWinStyle += ', top=' + Oben + ', left=' + Links + ', width=' +
> dieBreite + 'px, height=' + dieHoehe +'px';
> 
>     if(dieUrl!="")
>         var newWin = window.open (dieUrl, targetValue, szWinStyle);
>     else
>     {
>         var newWin = window.open ("about:blank", targetValue, szWinStyle);
>         newWin.document.Open();
>         newWin.document.Write(derInhalt);
>         newWin.document.Close();
>         
>     }
>     newWin.focus();
>     WinHandlesArr[WinHandlesArr.length] = newWin;
> 
>     return(true);
> }
> 
> //globales Array für Fenster handles
> var WinHandlesArr = new Array();
> 
> window.onunload = function ()
> {
>     for(var i=0;i<WinHandlesArr.length;i++)
>     {   if(WinHandlesArr[i]!=0)
>         {   if(!WinHandlesArr[i].closed)
>                 WinHandlesArr[i].close();
>         }
>     }
> }
> //##########################################################################
> #################
> 
> Online Example with popup as new window:
> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/select-feature-with
> -function.html
> 
> Arnd
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: openlayers-users-bounces at lists.osgeo.org
> [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Joel
> Leininger
> Gesendet: Samstag, 18. Juni 2011 01:13
> An: openlayers-users at lists.osgeo.org
> Betreff: [OpenLayers-Users] New Popup windows
> 
> I'm trying to create popups that are new windows, not part of the main map
> window. This seems like it should be fairly straightforward to do, but I'm
> only a novice javascript programmer, and I can't make heads nor tails out of
> the docs for OpenLayers.Popup.
> 
> I have Popup.FramedCloud working, and everything is correct with respect to
> its contents. I only need to have popup generate a new, stand-alone window.
> Can someone point me in the right direction?
> 
> Here is my FramedCloud (working) code:
> 
> var popup = null;
> info = new OpenLayers.Control.WMSGetFeatureInfo({
>             url:
> 'http://www.martenet.com/cgi-bin/mapserv?map=/home/public/sjm_ops/GeoData/BA
> -Grids.map',
>             title: 'Identify features by clicking',
>             queryVisible: true,
>             eventListeners: {
>                 getfeatureinfo: function(event) {
>                  if (!event.text.match(/<body>\s*<\/body>/)) {if (popup)
> {popup.destroy(); popup = null;}
>                    popup = new OpenLayers.Popup.FramedCloud(
>                                    "popup",
>                                    map.getLonLatFromPixel(event.xy),
>                                    null,
>                                    event.text,
>                                    null,
>                                    true
>                                    );
>                    map.addPopup(popup);
>                                                 }
>                             }
>                                                 }
>         });
>         map.addControl(info);
>         info.activate();
> 
> 
> Thanks in advance for any help.
> 
> -J.
> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 




More information about the Users mailing list