[OpenLayers-Users] how to adapt an api for my own wms layers

Robert Buckley robertdbuckley at yahoo.com
Wed Apr 18 02:31:15 EDT 2012


Hi,

I am using the Ushahidi framework and would like to serve my ownbasemaps which come from geoserver (wms and GeoWebCache)

There is a class in the Ushahidi framework which I have pasted underneath. It called the layers using the following parameters....

// OpenStreetMap Mapnik
$layer = new stdClass();
$layer->active = TRUE;
$layer->name = 'osm_mapnik';
$layer->openlayers = "OSM.Mapnik";
$layer->title = 'OSM Mapnik';
$layer->description = 'The main OpenStreetMap map';
$layer->api_url = 'https://www.openstreetmap.org/openlayers/OpenStreetMap.js';
$layer->data = array(
'baselayer' => TRUE,
'attribution' => '&copy;<a href="@ccbysa">CCBYSA</a> 2010
<a href="@openstreetmap">OpenStreetMap.org</a> contributors',
'url' => 'http://tile.openstreetmap.org/${z}/${x}/${y}.png',
'type' => ''
);
$layers[$layer->name] = $layer;

I would like to adapt this code for my own geoserver instance......but am not sure what/how to change it.

It references the OpenStreetMap.js file which defines the maps as this

/** * Class: OpenLayers.Layer.OSM.Mapnik * * Inherits from: *  - <OpenLayers.Layer.OSM> */
OpenLayers.Layer.OSM.Mapnik = OpenLayers.Class(OpenLayers.Layer.OSM, { /** * Constructor: OpenLayers.Layer.OSM.Mapnik * * Parameters: * name - {String} * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, options) { var url = [ "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png", "http://b.tile.openstreetmap.org/${z}/${x}/${y}.png", "http://c.tile.openstreetmap.org/${z}/${x}/${y}.png" ]; options = OpenLayers.Util.extend({ numZoomLevels: 19, buffer: 0, transitionEffect: "resize" }, options); var newArguments = [name, url, options]; OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); }, CLASS_NAME: "OpenLayers.Layer.OSM.Mapnik"
});

Can anyone see how I could adapt this code to use a wms or gwc layer coming from http://mydomain/geoserver/wms? with "layername"???

thanks for any suggestions,

yours,

Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120418/a5e233cf/attachment-0001.html


More information about the Users mailing list