I have a webpage, on which I am running Openlayers to query a WMS server.

Now, I want to provide my own data to Openlayers. I do not want to use a WMS server. I have a php script, which will generate tiles in png format, and I want to display them in Openlayers. The reason for not going with WMS is that I have 6 or higher dimensional data, and I will make two dimensional projections thereof, and I want Openlayers to treat this as a map.

How do I feed data to openlayers? I asked this question in the IRC, and also looked on the Internet. I didn't find much.

1 Answer 1


OpenLayers supports data via something called Layers

There are various types of Layers that OpenLayers Supports. Broadly speaking, Layers can be grouped into two major classes: Vectors and Image Based Layers. You have already created a php service to serve our PNG Images. Hence you need to use one of the Image based Layers.

I have no knowledge of your data, so I'm assuming that your data is spatial in nature. Your images (from the php script) will display the data at some particular location. Hence I'll suggest that you make your php service implement the WMS Specification. You need not implement all the specifications; You need to implement only those features which are used by OpenLayers' WMS Class.

To figure out which WMS operations are used by OpenLayers, I'll suggest that you play with one of the WMS OpenLayers Samples, and see which requests are being sent, by using FireBug or Fiddler.

For example, looking at the sample given at: WMS Example I could see that the following GET parameters were passed:

BBOX    0,45,11.25,56.25
FORMAT  image/jpeg
LAYERS  basic
WIDTH   256

Out of these, your php script will work, if you implement only the following three paramters: BBOX, HEIGHT & WIDTH. You could set the rest of the properties in your OpenLayers Application

  • I agree with the above answer, you should also look into OpenLayers.Layer.XYZ if you do not want to follow WMS rather create your own.
    – neogeomat
    Aug 5, 2013 at 4:15
  • @byom: The problem with XYZ layer, is that you need tiles in http://example.com/tiles/${z}/${x}/${y}.png url. Secondly, you will need to convert from (z,x,y) to a bounding box in the php script. Both of these issues can be solved, but they require additional code. A WMS-like service will be much simpler. Aug 5, 2013 at 6:42
  • Ofcourse, using WMS in client side will be much simpler. I suggested using OpenLayers.Layer.XYZ because the question says "I do not want to use a WMS server"
    – neogeomat
    Aug 5, 2013 at 9:30
  • @all if i need layer in TLD/Z/x/y then i can, after modifying the openlayers.layer.xyz cl<ass, also actually extent this directly to TLD/Z/x/y/a/b/c/proj_axis_1/proj_axis_2 . so that is also a good idea ...
    – Sean
    Aug 5, 2013 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.