So, just add a small check and it works. Line 487 of openlayers.mapclient, add

if (!isset($map['projection'])){
$map['projection'] = 'EPSG:4326';
}

solves the issue

Comments

jpulles’s picture

You could also add projection="EPSG:4326" to your [map /] specification?

Otherwise you need to clarify the problem a little: to what kind of object do you want to add a WMS layer? Do you have the url of capabilities? What is the [map /] spec you are using?

batje’s picture

I ment, when you add the WMS layer to Drupal not to a map, in the edit form.

So, press Create content, Map Layer, fill in the service URL, layers, SRS & extent.

Then press preview.

In the Openlayers code, the $map that is created does not have the SRS/Projection set. (which is somewhat logical, as you are not creating a map, just showing one)

I suggest to default to 'EPSG:4326' but ultimately, in this scenario, the projection of the map, should be the projection of the single layer that it is showing.

Sorry for the confusion.

jpulles’s picture

No problem. For a Map layer, the associated map should have a projection however, similar to the SRS of that layer.
You can check this by setting the logging to "info" in the tools section of the general mappingkit settings (?q=admin/mappingkit/general).
Having done this for the map layer at http://aardbodem.nl/?q=node/50, a map specification is shown as follows:

[map projection="EPSG:28992" extent="10000,305000,280000,619000" baselayers="none" title="Spoorwegen" layers="1" 1="wms|http://www.rijkswaterstaat.nl/services/geoservices/basispakket/nationaal...?|Spoorwegen|AAA58,AAA59,AAA53,AAA56,AAA57|queryable=true"/]

If your installation doesn't do similar things, I don't know what goes wrong. Do you have a url to the problem page?

batje’s picture

(sorry, running on localhost)

I think we are confusing eachother :-)

I am not creating a map as in a [map]

I am creating a node of type Layer. That Node will have a preview of itself, using openlayers.

Openlayers creates a map (not a [map] but an openlayer jscript $map), adds a projectection, and then adds the layer that you define in the node, to the map.

Because the $map is not based on a [map] but only on a single node of type layer, the code that sets the ($map['projection'] does not know which projection to use.

It should set the projection of the layer as the projection of the $map, but it doesn't. It creates a $map with an empty, undefined projection.

The code above, will at least, add a default projection of type 'EPSG:4326', if the $map['projection'] is not defined. That is not optimal, but will help in 80% of the cases.

jpulles’s picture

Assigned: Unassigned » jpulles

If you run at localhost, you can see logging of the mapping kit by adding &log=info to your url (assuming it already contains a ?).
The node type 'Map layer' is themed as a [map .../] specification; that was wat I tried to explain in the previous reply.
But you mention that it doesn't show the projection in the preview and indeed, at my localhost system it shows something like

[map projection="EPSG:" extent="3452.630859375,307189.125,278028.5,623690.25" baselayers="none" title="gwb_groot" layers="1" 1="wms|http://localhost/krw2007/cgi-bin/mapserver/mapserv.exe?map=nl/gwl.map&db...|gwb_groot|gwb_groot|queryable=true,info_format=text/plain"/]

Indeed, no epsg code in it, which needs to be fixed.

By the way, in case of [map ../] spec without an explicit projection, a default of EPSG:4326 is already assumed. The error in this case is an incorrect projection parameter.

Thanks!

jpulles’s picture

Title: When adding a WMS layer, the preview map has no projection set » When adding a Map layer, the preview map has no projection set
Status: Active » Fixed

Fixed in cvs and title changed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.