Google Earth adding placemarker with Google Maps coordinates - no placemarker appears

46 views
Skip to first unread message

David Faiz

unread,
Mar 3, 2014, 3:47:10 PM3/3/14
to google-earth-...@googlegroups.com
Hello all,

I am reading a XML file placing its contents into an array and then I am trying to place placemarker using the API, the location of the placemarker is incorrect

Here is the code:

    var markers = [];
var counter =0;
$.get('Customers.xml', function(xml) {
      var jsonObj = $.xml2json(xml);
        $.each(jsonObj.Marker, function(){
                 var mark = {
                        title: this.title,
                        latitude: this.latitude,
longitude: this.longitude,
                        icon: stat
                        }
                markers.push(mark);
        });
});  


    var ge;
    google.load("earth", "1", {"other_params":"sensor=true_or_false"});

    function init() {
      google.earth.createInstance('map3d', initCB, failureCB);
    }

    function initCB(instance) {
      ge = instance;
      ge.getWindow().setVisibility(true);
 
var lon = markers[counter].longitude;
var lat = markers[counter].latitude;
     var image = markers[counter].icon;
var custname = markers[counter].title;
 
 addplacemark (lon,lat,image,custname);
    }

function addplacemark (lon,lat,image,custname)
{
 // create the placemark
 var placemark = ge.createPlacemark('');

 // Define a custom icon.
var icon = ge.createIcon('');
var style = ge.createStyle(''); //create a new style
style.getIconStyle().setIcon(icon); //apply the icon to the style
style.getIconStyle().setScale(10.0);
placemark.setStyleSelector(style); //apply the style to the placemark
 
var point = ge.createPoint('');
point.setLatitude(lat);
point.setLongitude(lon);
placemark.setGeometry(point);
placemark.setName(custname);
 
// add the placemark to the earth DOM
ge.getFeatures().appendChild(placemark);

 } 
 


The coordinates are taken from Google Maps geocoding API.
No placemarker is placed, if I input the coordinates manually like so:

 point.setLatitude(52.3702157);
 point.setLongitude(4.8951679);

I do get a placemarker.
What can be the reason ?

Reply all
Reply to author
Forward
0 new messages