[OpenLayers-Users] Overlaying WMS layer on Google maps - help
Alexandre Dubé
adube at mapgears.com
Mon Aug 20 10:09:55 PDT 2012
Hi,
The OpenLayers.Layer.WMS class takes 4 arguments, see the constructor :
http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Layer/WMS-js.html
So, in your case, you're missing the 3rd argument, "params"
{object}. Adding this and having the "options" {object} as your last
argument should do the trick.
HTH,
Alexandre
On 12-08-20 11:43 AM, modala wrote:
> Hi, I am unable to overlay the WMS map on google maps. Can any one help me
> with this code
> function init(){
>
> /* The full extent/bounds to which the Map can be zoomed */
> var fullBounds = new OpenLayers.Bounds(-90, 0, 70, 30);
>
> /* Map variable is assigned a OpenLayers.Map */
> map = new OpenLayers.Map("map", {
> div: "map",
> controls:[
> new OpenLayers.Control.Navigation(
> {mouseWheelOptions: {interval: 100}}
> ),
> new OpenLayers.Control.PanZoomBar(),
> new OpenLayers.Control.Attribution(),
> new OpenLayers.Control.LayerSwitcher(),
> //new OpenLayers.Control.Permalink(),
> //new OpenLayers.Control.OverviewMap()
> ],
> maxExtent: fullBounds,
> projection: new OpenLayers.Projection("EPSG:900913"),
> displayProjection: new OpenLayers.Projection("EPSG:4326")
> });
>
> /* This is the stylemap which styles i.e. colors, borders, etc the
> selected features and clusters */
> var fStyle = new OpenLayers.Style({
> pointRadius: "${radius}",
> fillColor: "#ffcc66",
> fillOpacity: 0.8,
> strokeColor: "#cc6633",
> strokeWidth: 2,
> strokeOpacity: 0.8,
> label:"${count}",
> fontSize: "9px",
> fontWeight: "bold",
> }, {
> context: {
> radius: function(feature) {
> /* The radius of the cluster is set based on the
> number of features it contains*/
> return Math.min(feature.cluster.length, 7) + 3;
> },
> count: function(feature) {
> /* This displays the count of the features on the clusters */
> if (feature.cluster.length>1)
> return feature.cluster.length;
> else
> return "";
> }
> }
> });
>
> /* the Thesis variable is assigned a OpenLayers.Layer.Vector */
> thesis = new OpenLayers.Layer.Vector("Thesis", {
> projection: map.displayProjection,
> strategies: [
> new OpenLayers.Strategy.Fixed(),
> /* Using the cluster strategy clusters the features that are too close
> into clusters. */
> new OpenLayers.Strategy.Cluster({
> //distance:20 //This value can be changed to change the distance which
> defines when to form clusters
> })
> ],
> protocol: new OpenLayers.Protocol.HTTP({
> /* The path to the KML files*/
> url: "kml_final1.kml",
> //url: "georeferences_July19_2_modified.kml",
> format: new OpenLayers.Format.KML({
> extractAttributes: true,
> maxDepth: 1,
> })
> }),
> /* This style map says that the default style is the fstyle which is
> defined above, and upon selection, the one defined
> infront of 'select' gets activated */
> styleMap: new OpenLayers.StyleMap({
> "default": fStyle,
> "select": {
> fillColor: "#8aeeef",
> strokeColor: "#32a8a9",
> }
> })
> });
>
> /* This is an important function where once all the strategies are done
> loading i.e. the features are done loading, the
> set of features is assigned to the all_featuresArray which was
> initialized earlier.
> thesis.strategies[i] can be selected to choose either the clusters or
> the features, as per the order defined in the Vector */
> thesis.events.register("loadend", this, function(){
> all_featuresArray = thesis.strategies[1].features;
> });
>
> /* These are the base layers on top of which the Vector will be displayed
> */
> var gmap = new OpenLayers.Layer.Google("Google Streets", {numZoomLevels:
> 20, sphericalMercator: true} );
> var gmap_phy = new OpenLayers.Layer.Google("Google Hybrid", {type:
> google.maps.MapTypeId.HYBRID, numZoomLevels: 20, sphericalMercator: true});
> var osm = new OpenLayers.Layer.OSM('Open Street Maps',
> 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {numZoomLevels: 20,
> sphericalMercator: true} );
> var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
> "http://vmap0.tiles.osgeo.org/wms/vmap0", {isBaseLayer:false});
> wms.projection = (map.displayProjection, map.getProjectionObject())
> /* Add the above layers to the map */
> map.addLayers([ gmap, gmap_phy, osm, wms]);
> /* Add the vectors to the Map */
> map.addLayers([ thesis]);
>
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Overlaying-WMS-layer-on-Google-maps-help-tp4996413.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list