javascript - Store the longtitude and the latitude of a placemark into array -


so i'm working on webpage using google earth api shuttle moves around town , picks passengers. passengers predefined array of objects , separate javascript file due length. here code function populate populates 3d map placemarks:

function populate() { // mark houses (var house in houses) {     // plant house on map     new google.maps.marker({         icon: "https://google-maps-icons.googlecode.com/files/home.png",         map: map,         position: new google.maps.latlng(houses[house].lat, houses[house].lng),         title: house     }); }  // current url, sans filename var url = window.location.href.substring(0, (window.location.href.lastindexof("/")) + 1);  // scatter passengers (var = 0; < passengers.length; i++) {     // pick random building     var building = buildings[math.floor(math.random() * buildings.length)];      // prepare placemark     var placemark = earth.createplacemark("");     placemark.setname(passengers[i].name + " " + passengers[i].house);      // prepare icon     var icon = earth.createicon("");     icon.sethref(url + "/img/" + passengers[i].username + ".jpg");      // prepare style     var style = earth.createstyle("");     style.geticonstyle().seticon(icon);     style.geticonstyle().setscale(4.0);      // prepare stylemap     var stylemap = earth.createstylemap("");     stylemap.setnormalstyle(style);     stylemap.sethighlightstyle(style);      // associate stylemap placemark     placemark.setstyleselector(stylemap);      // prepare point     var point = earth.createpoint("");     point.setaltitudemode(earth.altitude_relative_to_ground);     point.setlatitude(building.lat);     point.setlongitude(building.lng);     point.setaltitude(0.0);      // associate placemark point     placemark.setgeometry(point);      // add placemark earth     earth.getfeatures().appendchild(placemark);      // add marker map     var marker = new google.maps.marker({         icon: "https://maps.gstatic.com/intl/en_us/mapfiles/ms/micons/man.png",         map: map,         position: new google.maps.latlng(building.lat, building.lng),         title: passengers[i].name + " @ " + building.name     });      //remember passenger's placemark , marker pick-up's sake     passengers[i].lat = placemark.getgeometry.getlatitude();     passengers[i].lng = placemark.getgeometry.getlongtitude(); } } 

however, when load page following error console: uncaught typeerror: undefined not function regarding 2 last lines of code:
passengers[i].lat = placemark.getgeometry.getlatitude(); passengers[i].lng = placemark.getgeometry.getlongtitude()

any ideas how can correctly lat , lng? thank in advance.

as others have said getgeometry method , needs brackets () executed.

also looking @ code can use building.lat , building.lng - these properties used set placemark's geometry in first place.

really pointless calling more methods, getgeometry().getlatitude(), value have.

the person @ building, no?

e.g.

passengers[i].lat = building.lat; passengers[i].lng = building.lng; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -