7

I want to convert longitude and latitude coordinates from WSG84 to Google Mercator. The following code-samples show my coordinates in a KML/KMZ file and where I need the coordinates in the javascript file.

<LatLonBox>
   <north>50.0</north>
   <south>46.0</south>
   <east>18.0</east>
   <west>13.0</west>
</LatLonBox>


new ol.layer.Image({
            source: new ol.source.ImageStatic({
                url: 'file:///C:/Users/Xhy/Desktop/cubic.png',
                imageExtent:[1447153.38031, 5780349.22026, 2003750.83428, 6446275.84102]
            })
        })

I am currently using this site here to convert my coordinates from WSG84 to Google Mercator.

I need to automate these conversion, since I have to create OSM-files with different image layers. I have the latitude and longitude in a KML/KMZ file, I can read out of it, and use the coordinates.

My problem is, these coordinates I extract from the KML/KMZ files are WSG84 but for java-script I need the coordinates in Google Mercator.

Any ideas how I can make this conversion inside the javascript file?

1 Answer 1

7

I'm not familiar with programming in JavaScript but in the OpenStreetMap Wiki there is a section describing "Mercator". Following this link you'll find a sample code snippet to tranform from lat long to mercator. I actually don't know if it's correct because I did not test the code.

1
  • 2
    thank you very much, dunnow how I missed that, but it really helped me, it was exactly that what I was looking for! Commented Mar 3, 2015 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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