Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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")); 
  {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")); 
  {fillColor: '#FF0000'};// coloring the point
var bounds = new OpenLayers.Bounds();


but it can't change the previous color eg: see this page

share|improve this question

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.


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});


See this jsfiddle

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

Your Answer


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.