[MapQuery] how to add an existing ol layer to mapquery

Volker Mische volker.mische at gmail.com
Tue May 15 10:23:13 EDT 2012


Hi Giuseppe,

where do you actually initialise the new layer? Is it already
initialised in ol_layer? It looks a bit strange that you use a WMS bit
have a Layer names osm.

Cheers,
  Volker

On 05/15/2012 04:07 PM, Giuseppe De Marco wrote:
> added in mapquery.core.js, at line 876:
> 
> <js code>
> /*
> example of initialization of an existing ol layer with mapquery:
> 
>     jQuery('#map').data("mapQuery").layers({
>             type:'existing_ol',
>             label:'Label that you prefer',
>            
> legend:{url:'http://mapserver.edugis.nl/cgi-bin/mapserv?map=maps/edugis/cache/population.map&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=Bevolkingsdichtheid_2010&format=image/png'},
>             ol_layer:osm, // its an new OpenLayer.Layer object name
>             });
> 
>  */
>         existing_ol: function(options) {
>             var o = $.extend(true, {}, $.fn.mapQuery.defaults.layer.all,
>                     $.fn.mapQuery.defaults.layer.raster,
>                     options);
>             var params = {
>                 layers: options.ol_layer,
>                 transparent: o.transparent,
>                 format: o.format
>             };
>             if(typeof o.wms_parameters != "undefined"){
>                 params = $.extend(params, o.wms_parameters);
>             }
>             return {
>                 layer: options.ol_layer,
>                 options: o
>             };
>         },        
> 
> </js code>
> 
> it simply works,
> any suggestion?
> 
> Thank you all
> g
> 
> ------------------------------------------------------------------------
> *Da:* Volker Mische <volker.mische at gmail.com>
> *A:* Giuseppe De Marco <peppelinux at yahoo.it>
> *Cc:* "mapquery at lists.osgeo.org" <mapquery at lists.osgeo.org>
> *Inviato:* Martedì 15 Maggio 2012 16:03
> *Oggetto:* Re: [MapQuery] how to add an existing ol layer to mapquery
> 
> On 05/15/2012 03:41 PM, Giuseppe De Marco wrote:
>> I'm tryng to add an existing OL layer inside mapquery, without create it
>> with $.MapQuery.Layer.
>>
>> Is it possibile without modify sources in  jquery.mapquery.core.js ?
> 
> Hi Giuseppe,
> 
> the best way would be to add a new layer type. You would do something
> like (just somewhere within your app):
> 
> $.extend($.MapQuery.Layer.types, {
>     yournewlayertype: function(options) {
>         // do some fancy stuff here
>         return {
>             layer: new OpenLayers.Layer.YourLayerType(),
>             options: options
>         };
>     }
> });
> 
> Then you can add a new layer to your MapQuery map with:
> mq.layers({type: 'yournewlayertupe'});
> 
> It's just like the layer definitions for the layers that are already
> defined in the ore. I hope you get the idea.
> 
> Cheers,
>   Volker
> 
> 



More information about the MapQuery mailing list