首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >具有Placemark功能的3D模型

具有Placemark功能的3D模型
EN

Stack Overflow用户
提问于 2012-10-20 02:49:39
回答 1查看 1.2K关注 0票数 0

我正在开发一个使用Google API和Sketchup的交互式地图。我已经使用以下代码创建并放置了3D对象:

代码语言:javascript
运行
复制
var loc = ge.createLocation('');
loc.setLatitude(lookAt.getLatitude());
loc.setLongitude(lookAt.getLongitude());
model.setLocation(loc);

// set up the model's link (must be a COLLADA file).
// this model was created in SketchUp
var link = ge.createLink('');
model.setLink(link);
link.setHref('http://earth-api-samples.googlecode.com/svn/trunk/' +
             'examples/static/splotchy_box.dae');

// create the model placemark and add it to Earth
var modelPlacemark = ge.createPlacemark('');
modelPlacemark.setGeometry(model);
ge.getFeatures().appendChild(modelPlacemark);

// zoom in on the model
lookAt.setRange(300);
lookAt.setTilt(80);
ge.getView().setAbstractView(lookAt);

// persist the placemark for other interactive samples
window.placemark = modelPlacemark;

来自此示例网站:http://earth-api-samples.googlecode.com/svn/trunk/demos/interactive/index.html

我正在尝试添加到3D模型的选项,一个常规的地标(所以它改变大小时,鼠标悬停&是可点击的)。

我对Google API比较陌生,所以我想知道:如何将这些函数添加到3D对象中?

我知道如何创建常规的placemark (来自同一网站),但我不知道如何将3D模型创建为placemark。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-01-28 12:50:38

var placemark是一个全局变量,这是在创建一个3D模型来代替一个placemark。试试这段代码,它对我很有效。我在这里使用了Google Earth插件。

代码语言:javascript
运行
复制
    function createPlacemark() {
        console.log("in create placemark");
        placemark = ge.createPlacemark('');
        placemark.setName('placemark ' + counter);

        var model = ge.createModel('');
        ge.getFeatures().appendChild(placemark);
        var loc = ge.createLocation('');
        model.setLocation(loc);
        var link = ge.createLink('');

        // A textured model created in Sketchup and exported as Collada.
        link.setHref('https://sites.google.com/site/siddharthuit/downloads/crane.dae');
        model.setLink(link);


        var la = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);

        // set location
        loc.setLatitude(la.getLatitude());
        loc.setLongitude(la.getLongitude());

        placemark.setGeometry(model);

        la.setRange(300);
        la.setTilt(45);
        ge.getView().setAbstractView(la);

    }

我还有一个问题,你知道如何根据数据库中动态给出的坐标来移动地标吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12980604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档