Reputation: 23
I'm want to create a kml with UTM coord when I set a new placemark. This is my code but I don't know where I have to set this property
//part of the code
counter++;
placemark= makePlacemark(hitTestResult.getLatitude(), hitTestResult.getLongitude(),
hitTestResult.getAltitude(), ge.ALTITUDE_ABSOLUTE, 'T');
//set placemark name
placemark.setName("PLM" + counter);
//set the placemark on the map
ge.getFeatures().appendChild(placemark);
var output = placemark.getKml();
alert(output);
function makePlacemark(lat, lng, alt, altMode, iconStr) {
var icon = ge.createIcon('');
icon.setHref('http://maps.google.com/mapfiles/kml/paddle/' + iconStr + '.png');
var style = ge.createStyle('');
style.getIconStyle().setIcon(icon);
style.getIconStyle().getHotSpot().set(0.5, ge.UNITS_FRACTION, 0,ge.UNITS_FRACTION);
var pt = ge.createPoint('');
pt.set(lat, lng, alt, altMode, false, false);
var pm = ge.createPlacemark('PLM' + counter);
pm.setGeometry(pt);
pm.setStyleSelector(style);
return pm;
}
You will need to transform (reproject) your coordinates from your UTM projection to epsg:4326
Does it means that Google Earth application uses additional transformations to show the coordinates in UTM? Used it Tools->Options
Upvotes: 1
Views: 6184
Reputation: 201
as stated in earlier posts you will need to convert your UTM coordinates to long lats
a good tool for this client side is: http://trac.osgeo.org/proj4js
see example:
http://trac.osgeo.org/proj4js/wiki/UserGuide
as also stated in an earlier post : destination coordinates epsg:4326 , the example has them as the source
source for proj4 will be your utms.
with proj4js, and UTM zone 10 north, http://spatialreference.org/ref/epsg/32610/ :
var dest= new Proj4js.Proj(‘EPSG:4236’);
var Source= new Proj4js.Proj(‘EPSG:32610’);
// transforming utm ngcoordinates
var p = new Proj4js.Point(489399,5456814);
Proj4js.transform(source, dest, p);
var lng= p.x ;
var lat= p.y;
Upvotes: 0
Reputation: 11
The best server-side coordinate transformation I've found is here:
http://www.jstott.me.uk/phpcoord/
I've used this for years in conjunction with my Google map and GE plugin code.
Anyone know a javascript equivalent?
Upvotes: 0