1

As it is said in the title i have to add a polygon in Google Earth which is integrated in a website. I managed to integrate Google Earth in the Website, so i can view the world but i can not use any functions like searching specific places or add paths. Does anybody know what i could do to fix this? Or did i used a wrong method to integrate Google Earth? I hope this is the right question for this forum.

Ps

0

What you are looking to do is draw a polygon onto the map using a series of coordinates for the inside and outside bounds. If you want a solid filled polygon, do not include the points for the inner shape. The following code would produce a polygon with a missing center. There are comments within to the code to help guide you as well. I hope this is what you're looking for.

// Create the placemark.
var polygonPlacemark = ge.createPlacemark('');

// Create the polygon.
var polygon = ge.createPolygon('');
polygon.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
polygonPlacemark.setGeometry(polygon);

// Add points for the outer shape.
var outer = ge.createLinearRing('');
outer.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
outer.getCoordinates().pushLatLngAlt(48.80, -121.80, 700);
outer.getCoordinates().pushLatLngAlt(48.80, -121.90, 700);
outer.getCoordinates().pushLatLngAlt(48.70, -121.90, 700);
outer.getCoordinates().pushLatLngAlt(48.70, -121.80, 700);
polygon.setOuterBoundary(outer);

// Add inner points.
var inner = ge.createLinearRing('');
inner.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);
inner.getCoordinates().pushLatLngAlt(48.77, -121.83, 700);
inner.getCoordinates().pushLatLngAlt(48.77, -121.87, 700);
inner.getCoordinates().pushLatLngAlt(48.73, -121.87, 700);
inner.getCoordinates().pushLatLngAlt(48.73, -121.83, 700);
polygon.getInnerBoundaries().appendChild(inner);

//Create a style and set width and color of line
polygonPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = polygonPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set('9900ffff');

// Add the placemark to Earth.
ge.getFeatures().appendChild(polygonPlacemark);

More information can be found on Google Earth for Developers, Geometries and Overlays.

  • Let me know if this works for you. – Cameron Sloan Jul 28 '15 at 15:34
  • If it got you to a solution that works for you will you please accept the answer so others can see that the answer has been provided. Thanks! – Cameron Sloan Aug 3 '15 at 14:21
  • For sure i am new here i didnt knew that. – Avanger12 Aug 4 '15 at 7:28
  • @Avanger12 I would suggest carefully looking through the tour for further guidance on how the site operates. Welcome to GIS Stack Exchange! – Cameron Sloan Aug 4 '15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.