<\/P>
Este exemplo para desenvolvedores demonstra como interagir com um edifício de vários andares em três dimensões usando a Esri<\/A> ArcGIS API for JavaScript<\/A> versão 4.3. Com uma simples operação de clique\/toque e arrastar, um edifício pode ser reposicionado de forma intuitiva e suave na superfície da Terra. Note que cada andar é um gráfico separado, mas são tratados como uma única entidade quando manipulados.<\/P><\/P>Clique aqui <\/A>para a aplicação ao vivo.<\/P>Clique aqui <\/A>para o código-fonte.<\/P><\/P>É importante notar que o exemplo usa algumas chamadas de API não documentadas para alcançar esse comportamento. Portanto, alertamos contra o uso dessas chamadas em um ambiente de produção, pois elas não são suportadas e provavelmente mudarão em um futuro próximo.<\/P><\/P>O código<\/A> pode parecer excessivamente ou desnecessariamente complicado, abaixo está um resumo do que o código faz:<\/P>Construção do Edifício<\/STRONG>Por razões de portabilidade, os andares do edifício são construídos a partir de um conjunto de valores codificados. É importante notar que cada andar é um gráfico individual atribuído com um identificador do edifício. Este identificador é usado para agrupar todos os andares adjacentes para realce e translação espacial.<\/LI>Arrastar<\/STRONG>O código usa o evento drag <\/A>do SceneView para responder às três fases da operação de arrastar do ponteiro, nomeadamente start<\/EM>, update<\/EM> e end<\/EM>. Durante a fase "start", é realizado um hittest <\/A>para identificar o andar do edifício (se houver) sob o ponteiro. Se um andar for encontrado, os andares adjacentes são identificados e destacados. Na fase "update", dois métodos não documentados SceneView._stage.pick<\/EM> e SceneView.<\/>_computeMapPointFromIntersectionResult<\/EM> são usados para rastrear o deslocamento do ponteiro em coordenadas do mundo real. Esses métodos retornam a localização no mapa diretamente sous <\/>o ponteiro, ignorando feições e gráficos.<\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/><\/>
Clique
É importante notar que o exemplo usa algumas chamadas de API não documentadas para alcançar esse comportamento. Portanto, alertamos contra o uso dessas chamadas em um ambiente de produção, pois elas não são suportadas e provavelmente mudarão em um futuro próximo.<\/P>
O
Vir Naidoo, I admire your curiosity and enthusiasm but I think that taking advantage of Esri's online training material might be a more effective way of gaining the necessary knowledge. On Esri's training page there are more than 30 JavaScript related courses most of which are either free or complimentary with a current maintenance subscription. For more information please contact your local Esri distributor.
and Richie Carmichael ,
Here is an another question, I have used your code,but the result is not right. the graphic.attributes.only have an OBJECTID attribute, did not include name or other.
So , how do you think to solve this??
thanks advance.
Hi Richie Carmichael ,
First, I am very grateful for your help , and this time i want to know is the graphic.attributes.name, where did it from ?
is it from the attributes table i have add it in my attributes table??
Vir Naidoo, to display the name of a clicked building you could do something like this:
_view.on("click", function (e) {
// Stop propagation.
e.stopPropagation();
// Perform hittest to get clicked building (if any).
_view.hitTest(e.screenPoint).then(function (p) {
if (!p || !p.results || p.results.length === 0) { return; }
var graphic = p.results[0].graphic;
if (!graphic) { return; }
// Popup name of clicked building.
alert(graphic.attributes.name);
});
I want to know if three is any way to achieve using click event in sceneView to find which building i have clicked? If so, how to achieve it,please show me the detail,thanks advance.
Vir Naidoo, click here to learn how to define a scene layer definition expression.
Hi Richie Carmichael ,
What you said is important to me , but how can i hide the building with definition query?
Do you have any demo that i can learn to??
thank you advance.
Hi Naidoo, no it is not possible to edit or move single features in a SceneLayer. But having said that I have seen one of my colleagues demonstrate a simulated editing workflow. When a user clicks on a building (from the SceneLayer) create a new graphic using the building's cloned geometry. Hide the clicked building using a definition query on the SceneLayer. Use the logic described in this post to translate the cloned building. Hope this helps!
I' d like to know could i use my buildings in sceneLayer to achieve this function???
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.