[OpenLayers-Users] map layers from extJS and php
MartinTsenov
mcenov at hsh.iccs.bas.bg
Mon Oct 12 05:43:50 EDT 2009
Hi Andreas,
First to add I am quit new for OL/extJS (working with since 1,5 month), I
think I defined
Spherical-Mercator correct (hope so):
map = new OpenLayers.Map('mymap', {
projection: "EPSG:900913",
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508,
20037508.34)
});
var gmap = new OpenLayers.Layer.Google("Google Streets", {
'sphericalMercator': true
});
map.addLayer(gmap);
It seems I am not able to see the dynamic layers, which I got from
Ext.data.Store/Php
only with "Ext.Viewport". When I defined "OpenLayers.Control.LayerSwitcher"
I can see
and switch between them in the drop-down menu of the
"OpenLayers.Control.LayerSwitcher".
And if a put the options "{isBaseLayer: true, visibility: ture}" in the
"OpenLayers.Layer.WMS"
for this dynamic layers, the are drawn on the map, but are not in
Ext.Viewport.
I was not aware of "http://geoext.org/" - now i am going to check it
Regards,
Martin
Andreas Hocevar-2 wrote:
>
> Hi,
>
> my guess would be that you are not using Spherical Mercator properly,
> which is required if you use google layers. See
> http://docs.openlayers.org/library/spherical_mercator.html
>
> On a side note: are you aware of http://geoext.org/ ?
>
> Regards,
> Andreas.
>
> MartinTsenov wrote:
>> Hi,
>>
>> I have problems to define map layers with php and extJS (Ext.data.Store)
>>
>> I am trying to define several map layers. I defined google and openStreet
>> map layers and now wanted dynamically to generate few more via
>> Ext.data.Store, Ext.data.JsonReader and php (for now php script just
>> return
>> some data, will be connect to postgre in the future). So the debugging
>> with
>> firebug shows that the data was received on the client side and seems to
>> be
>> well-formated
>> {"total":"int","layers":[{"name":"name","url":"urlData","layers":"layersMapFile"},]},
>> .I can see the objects with data via “firebug->DOM->map->layers” but the
>> dynamic layers are not displayed, only the google and openStreet are
>> there.
>> What could be the problem – am I missing something?
>>
>> Here is my code
>>
>> //Dynamic create WMS layer
>> var createWmsLayer = function(name, url, params, options) {
>> map.addLayer(new OpenLayers.Layer.WMS(name, url, params, options));
>> };
>>
>> store = new Ext.data.Store({
>> autoLoad: true,
>> id: 'store',
>> proxy: new Ext.data.HttpProxy({
>> url: 'layer_management.php',
>> method: 'POST'
>> }),
>> baseParams:{task: "LISTING"}, // this parameter is passed for any
>> HTTP
>> request
>> reader: new Ext.data.JsonReader({
>> idProperty: 'id',
>> root: 'layers',
>> totalProperty: 'total',
>> fields:[{name: 'name', mapping: 'name' },
>> {name: 'url', mapping: 'url'},
>> {name: 'layers', mapping: 'layers'}]
>> }),
>> listeners: {
>> 'load': function () {
>> store.data.each(function(item, index, totalItems ) {
>> createWmsLayer(
>> item.data['name'],
>> item.data['url'],
>> {
>> layers: item.data['layers'],
>> format: 'image/png',
>> transparent: true,
>> singleTile: true
>> },
>> {isBaseLayer: false, visibility: false}
>> )
>> console.info(item.data['name'] + ' : ' + item.data['url'] + '
>> : '
>> + item.data['layers']);
>> });
>> }
>> }
>> });
>>
>>
>> I use Ext.Viewport to show it:
>>
>> viewport = new Ext.Viewport({
>> layout: 'border',
>> items: [
>> new Ext.BoxComponent({
>> ......
>> height: 60
>> }),{
>> region: 'west',
>> title: 'LayerTree',
>> ........
>> collapsible: true,
>> items: [{
>> xtype: 'layertree',
>> map: map,
>> border: false
>> }]
>> },{
>> region: 'center',
>> ..........
>> margins: '5 5 0 0',
>> items: [{
>> xtype: 'mapcomponent',
>> map: map,
>> tbar: toolbar,
>> border: false
>> }]
>> },{
>> region: 'south',
>> ....
>> }
>> ]
>> });
>>
>>
>> Thanks in advanced
>>
>> Martin
>>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>
--
View this message in context: http://n2.nabble.com/map-layers-from-extJS-and-php-tp3712609p3806984.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list