[OpenLayers-Users] ImageLayer for dynamically generated images

"Stefan Jänicke" stefan.jaenicke at gmx.de
Tue Oct 25 05:58:52 EDT 2011


Hi Arnd.

That is exactly what I need, thank You.

> May be it's possible to add a function to the Image Layer Class, that use
> onload to get the image and the size.
I thought maybe the usage of the ImageLayer would be very much easier with an automatic size computation with the onload function ...

Best regards,
Stefan.

-------- Original-Nachricht --------
> Datum: Mon, 24 Oct 2011 18:17:51 +0200
> Von: "Arnd Wippermann" <arnd.wippermann at web.de>
> An: "\'\\"Stefan Jänicke\\"\'" <stefan.jaenicke at gmx.de>
> CC: users at openlayers.org
> Betreff: Re:[OpenLayers-Users] ImageLayer for dynamically generated images

> Hi,
> 
> You can use the javascript object Image() to get the size of an image.
> 
> Add the Image Layer to your map, perhaps with a blank image and use
> something like below 
> to retrieve your images and replace the previous of the Image Layer.
> 
> ...
> theImg = new Image();
> theImg.onload = addImageLayer;
> theImg.src = arrImages[imgCounter];
> ...
> 
> function addImageLayer()
> {
>     theWidth = theImg.width;
>     theHeight = theImg.height;
>     originX   = 0;
>     originY   = 0;
>     bounds    = new OpenLayers.Bounds(originX, originY, theWidth,
> theHeight);
> 
>     //map.setCenter(new OpenLayers.LonLat(theWidth/2,theHeight/2),0);
>     map.zoomToExtent(bounds);
> 
>     imageLayer.url=theImg.src;
>     imageLayer.extent=new OpenLayers.Bounds(originX, originY, theWidth,
> theHeight);
>     imageLayer.attribution = theImg.src.replace(/^.*\/(.*)$/,"$1");
>     imageLayer.setVisibility(false);
>     imageLayer.setVisibility(true);
>     $("Msg").innerHTML = "onload:" + imgCounter + ", " + theImg.src;
> 
> }
> 
> Example:
> http://gis.ibbeck.de/ginfo/apps/OLExamples/OL210/Swap%20Image%20Url/swap_ima
> ge_url.asp
>  
> 
> You need not only the size of the image, you need also the insert point of
> the image. Above I use 0,0.
> 
> May be it's possible to add a function to the Image Layer Class, that use
> onload to get the image and the size.
> 
> Arnd
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: openlayers-users-bounces at lists.osgeo.org
> [mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von "Stefan
> Jänicke"
> Gesendet: Montag, 24. Oktober 2011 11:04
> An: remi; users at openlayers.org
> Betreff: Re: Re:[OpenLayers-Users] ImageLayer for dynamically generated
> images
> 
> Hi Remi.
> 
> For sure, that is a possibility. But the problem is that I perform a
> request
> to a Contentserver2 instance, which receives the desired width and
> computes
> needed height of the image. I don't want to perform 2 requests (1 for
> image
> size, 1 for ImageLayer), since effort in Contentserver takes 1-2 seconds
> per
> request.
> 
> So is there a 1-request-way with OpenLayers for me?
> 
> Thanks,
> Stefan.
> 
> -------- Original-Nachricht --------
> > Datum: Sun, 23 Oct 2011 07:57:36 +0800
> > Von: remi <remiglobal at gmail.com>
> > An: "&quot,Stefan Jänicke&quot," <stefan.jaenicke at gmx.de>
> > Betreff: Re:[OpenLayers-Users] ImageLayer for dynamically generated 
> > images
> 
> > You can always use ur server side scripting language to get the size 
> > of your image. For example, in php, u can use gd extension to get the 
> > size of the image.
> > On Oct 22, 2011 11:41 PM, "&quot;Stefan Jänicke&quot;" < 
> > stefan.jaenicke at gmx.de> wrote:
> 
> -- 
> NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
> 
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de


More information about the Users mailing list