var ge;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCallback, failureCallback);
addSampleButton('Create a Circle!', buttonClick);
}
function initCallback(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
// add a navigation control
ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
// add some layers
ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
la.setRange(50000);
ge.getView().setAbstractView(la);
createCirclePolygon();
document.getElementById('installed-plugin-version').innerHTML =
ge.getPluginVersion().toString();
}
function failureCallback(errorCode) {
}
function createCirclePolygon() {
function makeCircle(radius, x, y) {
var center = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
var ring = ge.createLinearRing('');
var steps = 100;
var pi2 = Math.PI * 2;
for (var i = 0; i < steps; i++) {
var lat = 30 + x + radius * Math.cos(i / steps * pi2);
var lng = -85 + y + radius * Math.sin(i / steps * pi2);
ring.getCoordinates().pushLatLngAlt(lat, lng, 0);
}
return ring;
}
var polygonPlacemark = ge.createPlacemark('');
polygonPlacemark.setGeometry(ge.createPolygon(''));
var outer = ge.createLinearRing('');
polygonPlacemark.getGeometry().setOuterBoundary(makeCircle(0.1, 0, 0));
ge.getFeatures().appendChild(polygonPlacemark);
}
function buttonClick() {
createCirclePolygon();
}
嗨,我正在使用 Google Playground 构建一些代码来创建圆形多边形,我可以绘制圆形,我只想重定向我正在绘制圆形多边形的地图,但它正在重定向到其他地方(默认位置),我如何使用我的代码更改这个,任何帮助都非常感谢