Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:40:04+00:00 2026-06-11T04:40:04+00:00

I have Lat/Lon data coming in as GeoJSON and each point has additional properties

  • 0

I have Lat/Lon data coming in as GeoJSON and each point has additional properties associated with it. I need to be able to get these properties passed into the callback function when the KmlPlacemark is clicked. I know I can use closures and individually register event listeners on them but I’d really prefer just having a single listener on the GEWindow object.

My solution involves sticking the properties into the placemark id as JSON data.

var data = {foo: 123, bar: 321};
var placemark = ge.createPlacemark(JSON.stringify(data));

then in the callback it gets parsed back into an object

google.earth.addEventListener(ge.getWindow(), 'click', function(e){
  var target = e.getTarget(),
      data;
  if (target && target.getType() == 'KmlPlacemark'){
    data = JSON.parse(target.getId());
    myHandler(target, data);
  }
});

is there a less hacky way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:40:05+00:00Added an answer on June 11, 2026 at 4:40 am

    I found a solution I’m happy with. I use an incrementing id for the placemarks and I store the properties in a object using the id as the key.

    Dummy data

    var pointData = [
      {lat: 123, lon: 123, properties: {foo: 1, bar: 2}},
      {lat: 123, lon: 123, properties: {foo: 1, bar: 2}},
      {lat: 123, lon: 123, properties: {foo: 1, bar: 2}}
    ];
    

    Create Placemarks

    var properties = {},
        currentId = 0;
    
    pointData.forEach(function(point){
    
      var id        = (currentId++).toString();
          point     = ge.createPoint(''),
          placemark = ge.createPlacemark(id);
    
      point.setLatitude(point.lat);
      point.setLongitude(point.lon);
      placemark.setGeometry(point);
    
      properties[id] = point.properties;
    });
    

    Lookup properties in event handler

    google.earth.addEventListener(ge.getWindow(), 'click', function(e){
      var target = e.getTarget(),
          data;
      if (target && target.getType() == 'KmlPlacemark'){
        data = properties[target.getId()];
        myHandler(target, data);
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data set with over 50,000 geocoded points (lat-long). Each point has
I have lat, lon, data for a month data, I am working them to
I have created a method to retrieve some data (lat,lon points) and open a
I have data-set represented as latitude-longitude and a VALUE(named class) associated with each latitude-longitude
I have several file with the following format: lat,lon,value. I would like to plot
I have the following code but the lon/lat seems to be returning null; package
I have 3 points ( lat , lon ) that form a triangle.How can
i have a function to calculate several different values: int ASPfile::get_dimensions(int* Lat, int* Lon,
I have a lat/long coordinate point and I'm drawing a polygon (hexagon) around it
I have to work with strings which may contain Lat/Long data, like this: $query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.