0

i am using Mapserver map file and Openlayers to display a polygon layer on the Google map. layer is displaying but that layer is not on the center. i have used map.setcenter, but i do not know the lat lon values of the polygon layer how do Io get these polygon values?

1

If it's a vectorlayer you can use the getDataExtent()-Method. Otherwise you can also just set the extent manually, grab the centerpoint for this extent and use this centerpoint to center the map:

Just move the map to the extent you like and get the coordinates in your console:

map.events.register("moveend", map, function () {
    var centerpoint = map.getCenter().toShortString();
    console.log(centerpoint);
});

Of course you can also just use map.getCenter().toShortString() in your console without registering the moveend-event.

jsfiddle here: http://jsfiddle.net/expedio/osyvowg0/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.