Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My task is searching a single house from a layer and then zoom to the center. I did this part but i can't clearly identify this house. I am try to do this by adding a fillcolor to the searched area. but i can't.

var point1 = new OpenLayers.Geometry.Point(mins.x, mins.y);
            point1.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 
            point1.style={fillColor: '#FF0000'};// coloring the point
var point2 = new OpenLayers.Geometry.Point(maxs.x, maxs.y);
            point2.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); 
            point2.style={fillColor: '#FF0000'};// coloring the point
var bounds = new OpenLayers.Bounds();
            bounds.extend(point1);
            bounds.extend(point2);
            bounds.toBBOX();

            map.zoomToExtent(bounds); 

but it can't change the previous color eg: see this page https://gis.fatih.bel.tr/webgis/default.aspx

share|improve this question
add comment

1 Answer

What you have done is to define a bounds, and just zoomed to it.

What you need to do, is to create an geometry (either point or polygon), and add it to an empty vector layer. That it will be displayed as a graphic. You can style it according to your needs.

map.addLayer(wmsLayer);

var pt1=new OpenLayers.Geometry.Point(-2,-2);
var pt2=new OpenLayers.Geometry.Point(-2,2);
var pt3=new OpenLayers.Geometry.Point(2,2);
var pt4=new OpenLayers.Geometry.Point(2,-2);

var ring=new OpenLayers.Geometry.LinearRing([pt1, pt2, pt3, pt4]);
var poly=new OpenLayers.Geometry.Polygon([ring]);

var feat=new OpenLayers.Feature.Vector(poly, {}, {fillColor:'red', fillOpacity:0.4});

polygonLayer.addFeatures([feat]);

See this jsfiddle

share|improve this answer
1  
please post the code here so the answer is save from line breakage. –  underdark Apr 26 '13 at 17:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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