[GIS] OpenLayers bounds with Lat/Long

javascriptopenlayers-2

I am using a custom map with the TMS in OpenLayers. I know my high/low latitude and longitude points. In other words I know the exact bounds of my map image in Lat/Long.

Is there a way to use lat/long in the bounds? Or do I have to convert to Mercator? My bounds are pretty small – it only covers maybe 10 square miles and then I want to be able to draw circles on the map at specific lat/long locations – like draw a circle to highlight a gas station.

I am just a bit confused about the Bounds portion. Here is my code this far – use they Mercator bounds just to get my image to display:

function loadmap() {
        var get_my_url = function (bounds) {
        var res = this.map.getResolution();
        var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
        var z = this.map.getZoom();

        var path = z + "_" + x + "_" + y + "." + this.type;
        var url = this.url;
        if (url instanceof Array) {
            url = this.selectUrl(path, url);
        }
        return url + path;
    }

    var options = {
        maxExtent: new OpenLayers.Bounds(-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892),
        numZoomLevels: 5,
        units: 'm',
        projection: "EPSG:900913",
        displayProjection: new OpenLayers.Projection("EPSG:4326")
    };

    var map = new OpenLayers.Map(
    'wissmap',
    options
);

    var layer = new OpenLayers.Layer.TMS(
    'Aerial',
    '/custom/maps/',
    {
        type: 'jpg',
        getURL: get_my_url
    }
);



    map.addLayer(layer);
    map.setCenter([2048, 2048], 2);
}

Best Answer

Bounds is like a shape of a rectangle with two edges meaning two coordinates,no matter how it is small,It is still a rectangle.

If you go on with smaller bounds,I suggest that you can use center coordinate of bound object which can be calculated from OpenLayers functionality.

See getCenterLonLat function for OpenLayers.Bounds