Hi everyone,
I have a problem I can't solve. I want to create a point that have a radius
that scale according to zoom.
I think it have something to do with "this.map.getZoom()" only that what I get
is "this.map.getZoom()" instead of an integer?!
here is my code:
<html>
<head>
<title>OpenLayers Test</title>
<script type="text/javascript" src="js/OpenLayers.js"></script>
<script defer="defer" type="text/javascript">
/* Variables */
var map;
function init(){
/* Creating the Map Viewer */
/*In order to create the viewer, you must first create a map. The
OpenLayers.Map constructor requires one argument: This argument must either be
an HTML Element, or the ID of an HTML element. This is the element in which the
map will be placed.*/
map = new OpenLayers.Map("map", {
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(), /* Open the switch layers panel */
],
maxResolution: 'auto',
units: 'meters',
numZoomLevels: 6
});
/*Map Constructor*/
/* The next step to creating a viewer is to add a layer to the Map.
OpenLayers supports many different data sources, from WMS to Yahoo! Maps to
WorldWind. */
var basicMapLayer = new OpenLayers.Layer.Image(
"Map Image",
"images/maps/MapImage.jpg",
new OpenLayers.Bounds(0, 0, 510, 510),
new OpenLayers.Size(510, 510),
);
/* Adding Area layer */
var area = new OpenLayers.Layer.Vector("Area", {
styleMap: new OpenLayers.StyleMap({
fillColor: '#999999',
fillOpacity: 0.4,
pointRadius: this.map.getZoom() * 300,
strokeColor: 'white',
strokeOpacity: 1,
strokeWidth: 1,
})
});
var area_point = new OpenLayers.Geometry.Point(250, 250);
var area_point_Feature = new OpenLayers.Feature.Vector(area_point);
var areaFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(area_point),
{externalGraphic: 'img/marker.png', graphicHeight: 1, graphicWidth: 1});
area.addFeatures(area_point_Feature);
/* Layer Constructor */
/* In order to display the map, you must set a center and zoom level. In
order to zoom to fit the map into the window, you can use the zoomToMaxExtent
function, which will zoom as close as possible while still fitting the full
extents within the window. */
map.addLayers([basicMapLayer, area]);
map.addControl(new OpenLayers.Control.LayerSwitcher()); /* Open the switch
layers panel */
map.zoomToMaxExtent();
map.setCenter(new OpenLayers.LonLat(250, 250),4);
}
</script>
</head>
<body onLoad="init()">
<div style="width:100%; height:100%; border:#000 1px solid;
background:#143750;" id="map"></div>
</body>
</html>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users