1

When i navigate on my map , I receive the latitude and longitude, but I want them to be specified in degrees. I don't know what should I do please help this is my code:

        function toggleControl(element) {
            for(key in drawControls) {
                var control = drawControls[key];
                if(element.value == key && element.checked) {
                    control.activate();
                } else {
                    control.deactivate();
                }
            }
        }

        function allowPan(element) {
            var stop = !element.checked;
            for(var key in drawControls) {
                drawControls[key].handler.stopDown = stop;
                drawControls[key].handler.stopUp = stop;
            }
        }

         function handleMeasurements(event) {
        var geometry = event.geometry;
        var units = event.units;
        var order = event.order;
        var measure = event.measure;
        var element = document.getElementById('output');
        var out = "";
        if(order == 1) {
            out += "measure: " + measure.toFixed(3) + " " + units;
            //alert("measure " + measure.toFixed(3) + " " +
             //                   + units + " ");
        } else {
            out += "measure: " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>";
        }
        element.innerHTML = out;
    }

    function toggleControl(element) {
        for(key in measureControls) {
            var control = measureControls[key];
            if(element.value == key && element.checked) {
                control.activate();
            } else {
                control.deactivate();
            }
        }
    }

    function toggleGeodesic(element) {
        for(key in measureControls) {
            var control = measureControls[key];
            control.geodesic = element.checked;
        }
    }

    function toggleImmediate(element) {
        for(key in measureControls) {
            var control = measureControls[key];
            control.setImmediate(element.checked);
        }
    }
1

Check out this function, provided by Openlayers:

getFormmatedLonLat function, in the Openlayers.Utils object.

An use example:

var ns = OpenLayers.Util.getFormattedLonLat(point.lat, 'lat', 'dms');
var ew = OpenLayers.Util.getFormattedLonLat(point.lon, 'lon', 'dms');

The output must be a string like:

Xº Y' Z''

for each coordinate.

| improve this answer | |

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.