Open GoogleCodeExporter opened 9 years ago
By now I resolved the problem #1 with a trick: substitute a "," for the ".".
Here is the new code, compared to the previous. I added the code to have a
placemark,too; every time a set of coordinates is converted, a new placemark is
added:
// previous
<form NAME="earth">
<script type="text/javascript">
var ge;
google.load("earth", "1");
...............
function lookAt(lat, lng, alt, range) {
var la = ge.createLookAt('');
la.set(lat, lng, alt, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0,
range);
ge.getView().setAbstractView(la);
}
// new
<form NAME="earth">
<script type="text/javascript">
var ge;
var counter = 1; // create a counter for placemarks (see after)
google.load("earth", "1");
...............
function lookAt(lat, lng, alt, range) {
var la = ge.createLookAt('');
lat2=lat.replace(".",","); lng2=lng.replace(".",",");
// No error if "." is missing :)
la.set(lat2, lng2, alt, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, range);
ge.getView().setAbstractView(la);
// Create a placemark.
var placemark = ge.createPlacemark('');
placemark.setName("marker "+ counter);
// Set the placemark's location.
var point = ge.createPoint('');
point.setLatitude(lat2);
point.setLongitude(lng2);
placemark.setGeometry(point);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
ge.getView().setAbstractView(la);
// Increment the placemark counter
counter++;
}
And lastly, a button to remove the placemarks:
HTML:
<!-- Button to remove the placemarks, from last to first -->
<input type="button" tabindex="18" style="background-color: #EFEFEF;" value = "Rimuovi marker"
onClick ="remove_placemark()">
and the relative code:
function remove_placemark () {
last = ge.getFeatures().getLastChild(); // Last child in the list of objects.
ge.getFeatures().removeChild(last); // remove it
counter-- ; // Decrement placemark counter
}
The new web page is at
http://www.train-simulator.net/GPS_Viewer/M_E_C_M_L17m.html
A screen dump is at http://www.train-simulator.net/GPS_Viewer/M_E_C_M_L17m.jpg
Original comment by nccbi...@alice.it
on 21 Aug 2011 at 11:29
Original issue reported on code.google.com by
nccbi...@alice.it
on 21 Aug 2011 at 6:30