[OpenLayers-Users] Problem zooming to feature

boesiii boesiii at yahoo.com
Tue Mar 5 05:47:02 PST 2013


After I search a GeoJSON vector layer for a matching attribute I would like
to be able to zoom to the feature but it is not zooming to the correct
position.  My map projection is epsg4326.  

function init(){
    map = new OpenLayers.Map('map', {
        projection: epsg4326,
        displayProjection: epsg4326
        });

    var mh_layer = new OpenLayers.Layer.Vector("Manhole", {
        projection: epsg4326,
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: url_smh,
            format: new OpenLayers.Format.GeoJSON({
                extractStyles: true,
                extractAttributes: true
            })
        })
    });

    map.setCenter(new OpenLayers.LonLat(lon,lat).transform(new
OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), zoom);

   .... part of the code which centers the view on the feature...
   map.setCenter(new
OpenLayers.LonLat(feature.geometry.getBounds().getCenterLonLat()).transform(new
OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), 18);



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Problem-zooming-to-feature-tp5038550.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list