thanks, I had already viewed the examples, see my code and you can
help me.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="
http://www.google.com/jsapi?
key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-
Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"></script>
<script type="text/javascript">
google.load("earth", "1");
google.load("maps", "2.xx");
var ge = null;
var isMouseDown = false;
var lineStringPlacemark = null;
var coords = null;
var pointCount = 0;
var doc = null;
var placemark;
var dragInfo = null;
function init() {
google.earth.createInstance("map3d", initCB, failureCB);
}
function initCB(object) {
ge = object;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
doc = ge.createDocument('');
ge.getFeatures().appendChild(doc);
var geocoder = new google.maps.ClientGeocoder();
geocoder.getLatLng('{{ dados.endereco }},{{ dados.cidade }},
{{ estado.nome }},{{ dados.pais }}', pontoinicial);
//google.earth.addEventListener(ge.getGlobe(), 'mousemove',
onmousemove);
google.earth.addEventListener(ge.getGlobe(), 'mousedown',
onmousedown);
google.earth.addEventListener(ge.getGlobe(), 'mousedown',
onmouseclick);
google.earth.addEventListener(ge.getWindow(), 'mousedown',
placemarkmousedown);
google.earth.addEventListener(ge.getGlobe(), 'mousemove',
placemarkmousemove);
google.earth.addEventListener(ge.getWindow(), 'mouseup',
placemarkmouseup);
}
function pontoinicial(point){
if (point) {
var lookAt = ge.createLookAt('');
lookAt.set(point.y, point.x, 10, ge.ALTITUDE_RELATIVE_TO_GROUND, 0,
60, 20000);
ge.getView().setAbstractView(lookAt);
}
}
function onmousemove(event) {
if (isMouseDown) {
coords.pushLatLngAlt(event.getLatitude(), event.getLongitude(),
0);
}
}
function onmouseclick(event) {
// alert(event.getTarget().getType());
if (event.getTarget().getType() == 'GEGlobe'){
if (isMouseDown) {
coords.pushLatLngAlt(event.getLatitude(), event.getLongitude(), 0);
placemark = ge.createPlacemark('');
ge.getFeatures().appendChild(placemark);
var icon = ge.createIcon('');
icon.setHref('
http://maps.google.com/mapfiles/kml/paddle/red-
circle.png');
var style = ge.createStyle('');
style.getIconStyle().setIcon(icon);
placemark.setStyleSelector(style);
var point = ge.createPoint('');
point.setLatitude(event.getLatitude());
point.setLongitude(event.getLongitude());
placemark.setGeometry(point);
ge.getFeatures().appendChild(placemark);
}
if (lineString.getCoordinates().getLength() > 2){
convertLineStringToPolygon(lineStringPlacemark);
}
}
}
function convertLineStringToPolygon(placemark) {
var polygon = ge.createPolygon('');
var outer = ge.createLinearRing('');
polygon.setOuterBoundary(outer);
var lineString = placemark.getGeometry();
for (var i = 0; i < lineString.getCoordinates().getLength(); i++) {
var coord = lineString.getCoordinates().get(i);
outer.getCoordinates().pushLatLngAlt(coord.getLatitude(),
coord.getLongitude(),
coord.getAltitude());
}
placemark.setGeometry(polygon);
}
function placemarkmousedown(event){
if (event.getTarget().getType() == 'KmlPlacemark' &&
event.getTarget().getGeometry().getType() == 'KmlPoint') {
event.preventDefault();
var placemark = event.getTarget();
dragInfo = {
placemark: event.getTarget(),
dragged: false
};
}
}
function placemarkmousemove(event) {
if (dragInfo) {
event.preventDefault();
var point = dragInfo.placemark.getGeometry();
point.setLatitude(event.getLatitude());
point.setLongitude(event.getLongitude());
dragInfo.dragged = true;
}
}
function placemarkmouseup(event) {
if (dragInfo) {
if (dragInfo.dragged) {
event.preventDefault();
}
dragInfo = null;
}
}
function onmousedown(event) {
if (isMouseDown) {
isMouseDown = true;
coords.pushLatLngAlt(event.getLatitude(), event.getLongitude(),
0);
convertLineStringToPolygon(lineStringPlacemark);
placemark = ge.createPlacemark('');
ge.getFeatures().appendChild(placemark);
var icon = ge.createIcon('');
icon.setHref('
http://maps.google.com/mapfiles/kml/paddle/red-
circle.png');
var style = ge.createStyle('');
style.getIconStyle().setIcon(icon);
placemark.setStyleSelector(style);
var point = ge.createPoint('');
point.setLatitude(event.getLatitude());
point.setLongitude(event.getLongitude());
placemark.setGeometry(point);
ge.getFeatures().appendChild(placemark);
lineStringPlacemark = ge.createPlacemark('');
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
lineString.setTessellate(true);
lineString.setAltitudeMode(ge.ALTITUDE_CLAMP_TO_GROUND);
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle
();
lineStyle.setWidth(lineStyle.getWidth() + 2);
lineStyle.getColor().set('66ff0000');
var polyStyle = lineStringPlacemark.getStyleSelector().getPolyStyle
();
polyStyle.getColor().set('ddffffff'); // aabbggrr format
coords = lineString.getCoordinates();
coords.pushLatLngAlt(event.getLatitude(), event.getLongitude(),
0);
doc.getFeatures().appendChild(lineStringPlacemark);
} else {
isMouseDown = true;
lineStringPlacemark = ge.createPlacemark('');
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
lineString.setTessellate(true);
lineString.setAltitudeMode(ge.ALTITUDE_CLAMP_TO_GROUND);
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle = lineStringPlacemark.getStyleSelector().getLineStyle
();
lineStyle.setWidth(4);
lineStyle.getColor().set('ddffffff'); // aabbggrr formatx
lineStyle.setColorMode(ge.COLOR_RANDOM);
var polyStyle = lineStringPlacemark.getStyleSelector().getPolyStyle
();
polyStyle.getColor().set('ddffffff'); // aabbggrr format
polyStyle.setColorMode(ge.COLOR_RANDOM);
coords = lineString.getCoordinates();
coords.pushLatLngAlt(event.getLatitude(), event.getLongitude(),
0);
doc.getFeatures().appendChild(lineStringPlacemark);
}
}
function failureCB(object) {
}
function limparmapa(){
}
</script>
</head>
<body>
<div id='map3d_container' style='border: 1px solid silver; height:
600px; width: 600px;'>
<div id='map3d' style='height: 100%;'></div>
</div>
<br>
<!--<input type=button onclick='javascript:alert(doc.getKml())'
value='Show KML'>-->
</body>
</html>
> Polyplot by James Staffordhttp://
www.barnabu.co.uk/geapi/polyplot
> > Thanks- Ocultar texto entre aspas -
>
> - Mostrar texto entre aspas -