[OpenLayers-Users] Overlaying WMS layer on Google maps - help
modala
modala.raghuveer at gmail.com
Mon Aug 20 08:43:09 PDT 2012
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.
More information about the Users
mailing list