Я пытаюсь выяснить, как установить минимум, который кто-то может уменьшить. Я не хочу, чтобы люди могли полностью изменять масштаб изображения. Вот мой код.
{
OpenLayers.ImgPath = "http://js.mapbox.com/theme/dark/";
var map, vectors, controls;
//map = new OpenLayers.Map('map');
//var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
//"http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'});
vectors = new OpenLayers.Layer.Vector("Vector Layer");
// Build the map
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 10,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037500,
-20037500,
20037500,
20037500
)
};
map = new OpenLayers.Map('map', options);
// Layer definitions
var wms = new OpenLayers.Layer.TMS(
"MapBox Layer",
[ "http://mylayerurl.com/" ],
{ 'layername': 'luring', 'type': 'png' }
);
// Add layers to the map
map.addLayers([wms, vectors]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
//map.addControl(new OpenLayers.Control.Click());
map.events.register("click", map, function(e) {
var position = map.getLonLatFromPixel(e.xy);
});
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var size = new OpenLayers.Size(10,10);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('/themes/fairfood/images/dotmarker.png',size,offset);
var markets = [];
//alert(markets[0].field_longitude_value);
// Create objects from our data.
function addMarker(lng, lat, info) {
var pt = new OpenLayers.LonLat(lng, lat).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject());
// Convert to google's coordinates(approx.)
//- Marker build
marker = new OpenLayers.Marker(new OpenLayers.LonLat(pt.lon,pt.lat),icon.clone());
marker.id = j;
marker.title = markets[j].title;
marker.location = markets[j].field_address_value;
marker.daysandtimes = markets[j].field_daysandtimes_value;
markers.addMarker(marker);
marker.events.register("mousedown", marker, function() {
document.getElementById('markettitle').innerHTML = this.title;
document.getElementById('location').innerHTML = this.location;
document.getElementById('daysandtimes').innerHTML = this.daysandtimes;
});
}
for(j=0;j<markets.length;j++) {
addMarker(markets[j].field_longitude_value,markets[j].field_latitude_value);
}
// Set the starting point of the map.
map.setCenter(new OpenLayers.LonLat(-9676648.014, 5283869.595), 6);
</script>
}