With the basic app you've just built,
you can configure the initial state
of the map in a number of ways.
For documentation on all of the ways you
can configure it, using XML attributes,
look in the instructor notes below.
But for now we'll configure
a few attributes to show
something interesting.
So here's the layout that you had
just created with your fragment
containing the maps fragment.
And this gave you the default Google
maps that you've been using throughout.
But what we're going to do is
we're going to change this.
So we're going to take a look at
New York City with a flyover type view.
So first of all, there's going to be
a number of attributes on the fragment
that we're going to need to set.
And we're going to do these
using the Maps namespace.
So we need to tell the XML
about the Maps namespace first.
So I'm going to do that up here.
And you see,
we have XML namespace tool equals this.
We're going to create a new
XML namespace for our map.
And here are the details for
the XML namespace for map.
As you can see, xmlns:map is equal to
http://schemas.android.com/apk/res-au-
to/.
So this will give us the map attributes
that we can now add to our fragment.
Map attributes will consist of
things such as the latitude and
the longitude of what
you want to look at.
So the latitude and
longitude of the area in New York City
we're going to look at a la now.
Here you can see, I've added
the map camera target latitude and
map camera target longitude.
Don't worry about the red
underlines on them at the moment.
Now, when you're looking at a map,
you actually look at a map
through a virtual camera.
So you tell the camera
the target latitude and
longitude that it's going to look at.
So the latitude of downtown
New York City is 40.7484 and
the longitude is negative 73.9857.
But what this is going to do is, if you
remember when you first run the map,
you had a view from high in
orbit looking down on the Earth.
And this will do that, but it will
be looking down on New York City.
But all it's going to
do is shift the camera.
From being high in orbit looking down on
the equator to being high in orbit
looking down on New York City.
So we also want to move the camera so
we zoom down onto New York City.
And we'll change a couple of things.
I'm going to add them and
then talk through them one by one.
So these are the three
attributes that I've added.
The first is the Camera-Bearing.
The Camera-Bearing is the direction
that the camera is looking at,
with zero degrees being looking north,
180 degrees being looking south.
So as a result, you can see I'm
looking at 112.5 degrees, so
I'm kind of looking east
with my camera bearing.
Next is going to be the camera tilt, so
if you can imagine the camera when it's
looking straight down,
it's going to be tilted at 90 degrees.
But if I can change that to 65 degrees,
then the camera is going to be appearing
somewhat at an angle looking down, so
we have a nice 3-D isometric
view of the world beneath us.
And then finally is the Camera ZOOM.
The larger the number, the closer
you are to the surface of the Earth.
So if you can imagine a Camera ZOOM 0,
that's what we've had all along,
where the camera is way up.
Looking down on the Earth.
But with a Camera ZOOM 17, I'm going
down really close to the Earth.
And as you'll see, because I've
got a camera tilt of 65 degrees,
I'm getting a 3D view of
the skyscrapers in New York City.
And with the Camera ZOOM being 17,
I'm actually lower than the level
of some of these skyscrapers.
So, let's run the application and
see what it looks like.
So, now here we see the application
running on my tablet.
It gives us a view of downtown New York,
and I can actually scroll around and
see the city in three dimensions.
So I can see some of the skyscrapers
that are cylindrical in shape.
And as we had an earlier on,
we were actually looking the base of the
Empire State Building, and here you can
see the Empire State Building rising
out of the view of the camera.
Because the camera is actually lower
than the height of the building.
And as I zoom around New York City and
I pan around, we can take a look at some
of the interesting features
in some of the buildings.
For example, here is the United Nations
headquarters, overlooking the river.
Here are things like some of
the islands in the river itself, and
we can see the skyscrapers on them.
Sometimes, it takes a little while for
them to show up.
So you've effectively gotten
all of this for free,
you didn't need to set up anything to
get the 3D views or anything like that.
Just basically by the fact
that you tilted the camera and
were close enough into the earth,
to be able to see the 3D views.
If I were to zoom out you'll see,
I'm just going to see now a pan-view
of New York City without the 3D.
As I zoom out, you can see we
were facing towards the East,
looking out over Long Island.
When I zoom in over the city again, once
I get close enough we'll start seeing
the buildings and
the skyscrapers popping up.
And there they are.
Pretty simple,
just all of this was done just by
setting attributes on the map fragment.
Pretty cool, right?
باستخدام التطبيق الرئيس المُنشأ للتوّ،
يمكنك تهيئة الحالة الأولية
للخريطة باستخدام عدة طرق؛
للحصول على مستندات بكل طرق
التهيئة، باستخدام سمات XML،
راجِع ملاحظات المدرب أدناه.
ولكن الآن، سنقوم بتهيئة
بضع سمات لعرض
شيء شيق.
وعليه، إليك المخطط الذي أنشأتَه
لتوِّك بالجزء الخاص بك
مع جزء الخرائط.
وهذا ما يعطيك خرائط Google الافتراضية
التي اعتدتَ استخدامها في كل شيء.
إلا أن ما سنفعله
هو أننا سنغير هذا.
بحيث سنلقي نظرة على
مدينة نيويورك بإسقاط فوقي.
لهذا؛ سيكون هناك أولاً عدد من
السمات في الجزء
وهذا ما سنحتاج إلى إعداده.
وذلك باستخدام
مساحة اسم الخرائط.
وعليه، نحتاج إلى تعريف XML
بمساحة اسم الخرائط أولاً.
سأفعل ذلك هنا.
كما ترى،
لدينا أداة لمساحة اسم XML تساوي هذا.
سنبدأ بإنشاء مساحة اسم
XML جديدة لخريطتنا.
إليك تفاصيل
مساحة اسم XML للخريطة.
كما ترى،
xmlns:map مساوية لـ
http://schemas.android.com/apk/res-au-
to/.
وهذا ما سيعطينا سمات الخرائط
التي يمكننا الآن إضافتها إلى جزئنا.
تتكون سمات الخرائط من
أشياء مثل: خط عرض،
وخط طول ما تريد
البحث عنه.
سنلقي نظرة على خط عرض،
وخط طول المنطقة في مدينة نيويورك
الآن.
يمكنك أن ترى هنا، أننا
أضفنا خط العرض المستهدف لكاميرا الخريطة
وخط العرض المستهدف لكاميرا الخريطة
لا تقلق من الخطوط السفلية
الحمراء الآن!
الآن، عندما تشاهد خريطة،
فإنك تشهدها من خلال
كاميرا افتراضية.
وعليه، فأنت تعرف الكاميرا
بخط العرض المستهدف
وكذلك خط الطول الذي ستستعرضها به.
وبالتالي يكون خط عرض
نيويورك 40.7484
بينما خط الطول العكسي 73.9857.
وما يفعله ذلك هو أنك، إذا كنت تذكر،
فإن أول مرة يتم فيها تشغيل الخريطة
تحصل على رؤية
تسقط من الفلك إلى الأرض.
وهذا ما يفعله ذلك، ولكنه سيستعرض
مدينة نيويورك.
فكل ما سيفعله
هو تغيير اتجاه الكاميرا.
ليكون مرتفعًا في الفلك
متجهًا صوبَ الأرض
أن يكون خط الاستواء مرتفعًا في الفلك
متجهًا صوب مدينة نيويورك
ولكننا نريد تحريك الكاميرا بحيث
نتمكن من تكبير مدينة نيويورك.
وعليه، سنغير بضع أشياء.
سأضيفها ثم
أتحدث عن كل واحد منها على حدة.
معنا الآن ثلاث سمات
أضفتها؛
أولها: اتجاه الكاميرا.
يعبر اتجاه الكاميرا عن الاتجاه
الذي تنظر إليه الكاميرا.
عند الصفر تكون متجهة صوب الشمال،
وعند 180 صوب الجنوب.
وعليه، يمكنك أن تلاحظ أنني
أنظر بدرجة 112.5
ومن ثم، فأنا أنظر شرقًا
حسب اتجاه الكاميرا.
أما التالي فيكون ميل الكاميرا، وعليه
إذا استطعت تخيل الكاميرا عندما تكون
متجهة لأسفل مباشرة،
فستكون مائلة بزاوية 90 درجة.
ولكن إذا غيرنا الزاوية إلى 65،
ستظهر الكاميرا
إلى حد ما بزاوية تتجه لأسفل،
ومن ثم يكون لدينا عرض رائع
ثلاثي ومتساوي الأبعاد للعالم أسفلنا.
وفي النهاية نحصل على وضع التكبير بالكاميرا.
كلما زاد الرقم، كنتَ أقرب
إلى سطح الأرض.
ومن ثم، إذا استطعت أن تتخيل أن تكبير الكاميرا 0،
وهذا ما نحصل عليه أغلب الوقت،
عندما تتجه الكاميرا إلى أعلى.
عندما تتجه لأسفل صوب الأرض.
ولكن عندما يبلغ تكبير الكاميرا 17، فبذلك
أتجه بالفعل صوب الأرض.
وكما سترون، فلديَّ
ميل كاميرا بدرجة 65،
لأحصل على عرض ثلاثي الأبعاد
لناطحات السحاب بنيويورك.
ومع درجة تكبير الكاميرا عند 17،
أكون بالفعل أقل من مستوى
بعض ناطحات السحاب.
حسنًا، دعنا نشغل التطبيق
ونرى كيف يبدو.
نرى الآن التطبيق يعمل
على جهازي اللوحيّ.
ويعرض لنا نظرة على وسط نيويورك،
كما يمكنني التمرير عبر المدينة
لرؤيتها ثلاثية الأبعاد.
كما يمكنني رؤية بعض ناطحات السحاب
أسطوانية الشكل.
وكما رأينا سابقًا،
فإننا كنا نبحث بالفعل عن قاعدة
مبنى إمباير ستيت، هنا يمكنك
رؤية مبنى إمباير ستيت يظهر
في عرض الكاميرا.
لأن الكاميرا أقل بالفعل من
ارتفاع المبنى.
ومع التكبير عبر مدينة نيويورك
والتجول خلالها، يمكننا إلقاء نظرة على بعض
المعالم الشيقة في
بعض المباني.
فمثلا، إليك مقرات الأمم
المتحدة المطلة على النهر.
وأشياء كبعض الجزر
داخل النهر نفسه،
يمكننا رؤية ناطحات السحاب عليها.
أحيانًا، قد تستغرق وقتًا
لتظهر.
بهذا تكون قد رأيتَ كل هذا
مجانًا.
فلن تحتاج إلى تثبيت أي شيء
للحصول على عرض ثلاثي أو شيء كهذا.
ولكن في الواقع
هي أنك ضبطت ميل الكاميرا
وكنت قريبًا بما يكفي من الأرض
لترى العرض ثلاثي الأبعاد.
وإذا تسنى لك التصغير فسترى،
سأستعرض الآن عرض بتدوير محوري
لنيويورك بدون التأثير ثلاثي الأبعاد.
مع التصغير، يمكنك أن تتبين
أننا كنا نتجه صوب الشرق،
نستطلع عبر لونغ آيلند.
عند تكبير عرض المدينة مرة أخرى،
بمجرد أن أقترب سنبدأ نشاهد
المباني وناطحات
السحاب تنبثق بشكل غير متوقع.
إليك شكلها.
بسيطة للغاية،
وكل هذا تم فقط من خلال
إعداد السمات على جزء الخريطة.
أليس رائعًأ؟
방금 만든 기본 앱에서
우리는 여러 가지 방법으로 지도의 최초 상태를 설정할 수 있습니다.
설정한 모든 방법을 문서화해서, XML을 상요하여서,
아래 지도자 노트를 봅시다.
그러나 지금 우리는 흥미로운 무언가를 보여주기 위해서 몇 가지 속성을
설정해 볼 것입니다.
그러므로 지도 프래그먼트가 포함된 프래그먼트와 함께 방금 만들어낸
레이아웃이 여기 있습니다.
그리고 우리가 사용한 초기설정 구글맵이 여기 있습니다.
그러나 우리가 해야 할 일은 이것을 바꾸는 것입니다.
그러므로 우리는 상공에서 촬영한 조감도로 뉴욕시를 보도록 하겠습니다.
맨 처음으로, 우리가 설정해야 하는
프래그먼트에 대한 다수의 속성이 있습니다.
그리고 우리는 지도 네임스페이스를 사용해서 이 일을 할 것입니다.
그러므로 우리는 먼저 지도 네임스페이스에 대한 XML을 말해보도록 하겠습니다.
그러므로 저는 위에서 이 일을 해보겠습니다.
그리고 보시는 바와 같이 우리는 XML 네임스페이스 도구가 이것과 같다는 사실을 압니다.
우리는 지도에 새로운 XML 네임스페이스를 만들겁니다.
그리고 여기에 지도를 위한 XML 네임스페이스를 위한 세부 사항이 있습니다.
보시는 바와 같이 xmlns:map은
http://schemas.android.com/apk/res-au-
to/와 같습니다.
그러므로 이로써 우리는 프래그먼트에 더할 수 있는 지도의 속성값을 얻습니다.
지도의 속성값은 우리가 보고자 하는 장소의 위도와 경도 같은
것들로 구성될 것입니다.
그러므로 우리가 지금 보려고 하는 뉴욕시 지역의
위도와 경도가 됩니다.
여기에서 우리는 지도 카메라 목표 경도와 지도카메라 목표 위도를
더합니다.
잠시 뜨는 붉은색 및줄에 대해서 걱정하지 않아도 됩니다.
이제, 지도를 볼 때
우리는 정말로 가상 카메라를 통해서 지도를 보고 있습니다.
그러므로 카메라가 보고 있는 목표 위도와 경도를
말해봅시다.
그러므로 뉴욕시 시내의 위도는 40.7484이고
경도는 -73.9857입니다.
그러나 만약 처음 지도를 작동시킬 때
지구위에서 아래를 내려다보는 궤도에서 높은 곳으로부터 뷰를 볼 수 있었다는 사실을 기억한다면
그리고 이것을 이렇게 한다면, 그러나 이것이 뉴욕 시를 내려다 보게 될 것이라면,
해야 하는 모든 일은 카메라를 변경하는 일입니다.
궤도를 따라 높은 곳에서 보았을 때,
뉴욕시에서 내려다보는 궤도에서 높은 곳에서 적도를 내려다보게 되기 때문에
우리는 카메라를 옮기기를 바라고 그러므오 우리는 뉴욕시를 줌해서 아래로 내려다보게 됩니다.
그리고 우리는 몇 가지를 바꾸어 보겠습니다.
저는 저들을 더하고 그 뒤에 하나씩 이야기해보려고 합니다.
그러므로 이들은 제가 더한 세 가지 속성입니다.
첫 번째가 카메라 베어링입니다.
카메라 베어링은 카메라가 보고 있는 방향입니다.
북쪽을 바라보는 쪽이 0도이고, 남쪽을 바라보는 가도가 180도입니다.
결과적으로 저는 112.5도를 찾고 있고,
그러므로 저는 제 카메라 베어링으로 동쪽을 찾고 있다고 말할 수 있겠죠.
다음은 카메라 기울기가 되겠는데요, 그러므로 만약 메라가 아래를
똑바로 내라다보는 카메라를 상상할 수 있다면, 카메라는 90도로 기울어지게 될 것입니다.
그러나 만약 제가 65도로 저것을 변경시키고
카메라가 아래를 내려다보는 각도에서 무언가가 나타나게 된다면
저는 우리 아래 세계를 보여주는 훌륭한 3-D 뷰를 갖게 됩니다.
그리고 그 뒤에 마지막으로 카메라 줌을 봅시다.
수가 커지면 커질수록 지도의 표면에 더 가까이 가게 됩니다.
만약 카메라 줌을 0으로 한다고 상상할 수 있다면,
카메라가 훨씬 높이 있는 지점에서 우리가 무언가를 볼 수 있다는 사실을 의미합니다.
지구에서 아래를 내려다 봅시다.
그러나 카메라 줌 17에서 저는 정말로 지구와 가깝게 됩니다.
그리고 보시다시피 제가 65도로 카메라를 기울였기 때문에
저는 뉴욕시의 마천루를 3d로 볼 수 있습니다.
그리고 카메라 줌을 17로설정하면서
저는 마천루 가운데 일부의 높이를 더 낮추어 볼 시 있습니다.
그러므로 앱을 실행하여 이것이 무엇처럼 보이는지 봅시다.
이제 여기에서 우리는 제 태블릿에서 실행되는 앱을 봅니다.
이때문에 우리는 뉴욕 시가를 볼 수 있고 저는 실제로 스크롤을 끌어당기고
3차원으로 도시를 볼 수 있습니다.
저는 모양이 원기둥인 마천루를 보고 있습니다.
이전에 공부한 것과 같이,
우리는 실제로 엠파이어 스테이트 빌딩을 보고 있습니다. 그리고 여기에서
카메라 뷰에서부터 엠파이어스테이트 빌딩을 볼 수 잇습니다.
카메라가 건물의 높이보다 실제로 낮기 때문에
그리고 제가 뉴욕시를 줌해서 보고 카메라를 이리저리 옮기고 있기 때문에 우리는
빌딩에서 흥미로운 특징을 엿볼 수 있게 됩니다.
예를 들어서 여기에 강을 내려다 보는 UN의 본부가 있습니다.
여기에 강 위의 섬 일부를 볼 수 있고요
우리는 그 위의 마천루를 볼 수 있습니다.
이따금 저들을 보는데 약간의 시간이 걸립니다.
그러므로 여러분은 공짜로 이 모든 것들을 보고 있는 셈입니다.
우리는 3D 뷰나 그와 비슷한 무언가를 설정할 필요가 없었습니다.
기본적으로 우리가 카메라를 기울임으로써
그리고 대지에 충분히 다가감으로써, 3d 뷰를 볼 수 있는 거죠.
만약 제가 줌아웃을 했다면, 우리는 이런 모습을 보게 될 것이고,
저는 이제 3d 없이 팬-뷰로 뉴욕시를 보겠습니다.
제가 줌아웃을 할 때, 우리는 동쪽으로 접한 모습을 볼 수 있습니다.
긴 섬을 내려다보면서 말입니다.
제가 다시 도시를 줌인해서 보면, 저는 충부히 가까운 곳에서 볼 수 있고
다시 한 번 마천루와 건물이 튀어나오는 것을 보게 될 것입니다.
그리고 거기에 이들이 있습니다.
상당히 단순하죠.
지도 프래그먼트 위에 속성값을 설정함으로써 이 모든 일을 할 수 있었습니다.
상당히 멋지지 않나요?
Com esse aplicativo básico
que acabou de compilar,
você poderá configurar o estado inicial
do mapa de várias maneiras.
Consulte as notas do instrutor
para ver a documentação sobre
todas as formas de configuração
usando os atributos XML.
Mas, por enquanto, vamos configurar só
alguns atributos para mostrar
uma coisa interessante.
Esse é o layout que você acabou
de criar com o seu fragmento
contendo o fragmento de mapas.
E isso forneceu o
Google Maps padrão que você
usou o tempo todo.
Porém, agora vamos
mudar isso.
Vamos olhar uma vista aérea da
cidade de Nova York.
Primeiramente, haverá uma
série de atributos
no fragmento que
teremos que definir.
Faremos isso
usando o namespace Maps.
Temos que informar ao XML
sobre o namespace Maps primeiro.
Vou fazer isso aqui em cima.
E você pode ver que temos
a ferramenta de namespace XML igual a isso.
Vamos criar um novo
namespace XML para o nosso mapa.
E aqui estão os detalhes do
namespace XML para o mapa.
Como você pode ver, xmlns:map é
igual a
http://schemas.android.com/apk
/res-au-to/.
Isso nos fornecerá os atributos do mapa
que podemos adicionar
ao nosso fragmento.
Os atributos do mapa serão formados
por coisas, como a latitude
e a longitude do local para onde
você quer olhar.
Então, é a latitude e a longitude
da área em Nova York
para a qual vamos olhar agora.
Aqui você pode ver que eu adicionei
a latitude e a
longitude do alvo da câmera do mapa.
Não se preocupe com os sublinhados
vermelhos ainda.
Agora, você está olhando para um mapa,
você olha para um mapa
por meio de uma câmera virtual.
Você informa à câmera a
latitude e longitude
do alvo para onde vai olhar.
Então, a latitude do centro de
Nova York é 40.7484
e a longitude
é -73.9857.
Mas, na realidade, o que isso vai fazer é...
você deve se lembrar de que quando executou o mapa primeiro,
tinha uma vista
de cima em órbita
voltada para baixo na Terra.
E é isso que vai acontecer aqui, mas vamos estar
olhando para Nova York.
Só a
posição da câmera vai mudar.
Do alto em órbita
olhando para baixo no Equador
para o alto em órbita
olhando para baixo para Nova York.
Nós também queremos mover a câmera,
então a aproximamos para baixo, para Nova York.
E vamos mudar
algumas coisas.
Vou adicioná-las e depois
explicar uma de cada vez.
Esses são os três
atributos que eu adicionei.
O primeiro foi Camera-Bearing.
Camera-Bearing é a direção para
a qual a câmera está apontada,
com zero grau para o Norte e
180 graus para o sul.
Como resultado, estou olhando a
112.5 graus
em direção Leste
com a minha câmera.
Em seguida, adicionei a inclinação da câmera.
Imagine que a câmera
apontada para baixo
estará inclinada a 90 graus.
Se eu mudar para
65 graus,
a câmera vai parecer estar
em um ângulo
olhando para baixo, então teremos uma vista
isométrica em 3-D do mundo
abaixo de nós.
E, por fim, o ZOOM da câmera.
Quanto maior o número, mais perto
você está da superfície da Terra.
Se você imaginar uma câmera com
ZOOM 0, é isso que vimos
o tempo todo,
quando a câmera está totalmente em cima.
Olhando para baixo, para a Terra.
Mas, com uma câmera com ZOOM 17, estarei mais
em baixo, muito perto da Terra.
E como você vai ver, como a câmera
está inclinada a 65 graus,
tenho uma visão em 3D
dos arranha-céus de Nova York.
E com a câmera com o ZOOM em 17,
estou mais baixo do que o nível
de alguns desses edifícios.
Vamos executar o aplicativo
para ver o que acontece.
Agora, estou executando o aplicativo
no meu tablet.
Temos uma vista do centro de
Nova York e eu posso mudar a
posição e ver a cidade
em três dimensões.
Vejo alguns arranha-céus
cilíndricos.
Anteriormente,
estávamos olhando para a base
do Empire State Building,
e aqui você pode ver
o Empire State Building crescendo
pela vista
da câmera.
Porque a câmera está mais baixa
do que a altura do edifício.
Conforme aumento o zoom em Nova York
e movo a câmera ao redor, podemos ver algumas
coisas interessantes
em alguns edifícios.
Por exemplo, essa é a sede da United
Nations,
de frente para o rio.
Essas são algumas ilhas
do rio,
e podemos ver os arranha-céus
nelas.
Às vezes, demora um pouco
para as coisas aparecerem.
Você tem tudo isso
de graça,
não foi preciso configurar
nada para obter as vistas em 3D
.
Basicamente, bastou
inclinar a câmera
e chegar perto o suficiente da Terra
para ver as vistas em 3D.
Se eu afastar o zoom,
vou ter uma vista panorâmica de
Nova York sem 3D.
Quando eu afastar o zoom, você verá
que estamos voltados para o Leste
com vista sobre Long Island.
Quando aproximo o zoom da cidade de novo,
quando estivermos próximos o suficiente,
começaremos a ver os edifícios
e os arranha-céus.
E aqui estão eles.
Muito simples! E tudo isso foi feito
definindo atributos no fragmento
do mapa.
Muito bacana, certo?
使用刚刚建置的基本应用,
您可以采用多种方式
配置地图的初始状态。
要获得您对地图进行配置可以使用
的所有方式的 XML 属性文档,
请在以下讲师注释中寻找。
但现在,我们将配置
一些属性以显示
有趣的功能。
这是您刚刚使用片段
创建的包含地图片段的
布局。
通过这种方式,您可以获得
自始至终使用的默认 Google 地图。
不过,我们要
进行更改。
我们看一下采用飞越视图类型
的纽约城。
首先,关于我们需要设置
的片段,存在
很多属性。
我们将使用 Maps 命名空间
执行这些操作。
首先,需要将 Maps 命名空间
告知 XML。
现在我将执行该操作。
您可以看到,
我们的 XML 命名空间工具是这样的。
我们将为应用创建
新的 XML 命名空间。
这是地图所用 XML 命名空间的
详细信息。
您可以看到,xmlns:map 表示
http://schemas.android.com/apk/res-au-
to/。
通过这种方式,我们将获得
可以立即添加到片段的地图属性。
地图属性包括
诸如您希望观看地点
的经纬度
等信息。
现在我们看一下
纽约城中区域
的经纬度。
在这里您可以看到,我已经添加了
地图摄影目标纬度
与地图摄影目标经度。
此刻别担心
它们底部的红线。
现在,在您观看地图时,
实际上是通过
虚拟摄像头来观看地图。
所以,需要将您要观看的
地点的经纬度
告诉摄像头。
纽约城市区的纬度
是 40.7484,而经度
是 -73.9857。
这样做有什么作用呢?
如果您还记得,第一次运行应用的时候,
当时您从高空的轨道中
俯视地球。
现在作用也是这样的,不过
俯视的将是纽约城。
只需要移动
摄像头就可以了。
从在高空的轨道中俯视赤道的位置
移动到从高空的轨道中
俯视纽约城的位置。
此外,我们还希望移动摄像头,
以便拉近到纽约城上空。
接下来更改一些属性。
我将添加这些属性,
然后逐一讨论。
这些是我已经添加的
三个属性。
第一个是摄像头方位角。
摄像头方位角是
摄像头面向的方向,
零度表示面向北方,
180 度表示面向南方。
您可以看到
我设置了 112.5 度,
因此,我的摄像头方位角
有点面向东方。
下一个属性是摄像头倾斜度,
您可以想象摄像头径直俯视的状况,
这时摄像头
以 90 倾斜。
不过,如果我将倾斜角度更改为 65 度,
摄像头将以某个角度
俯瞰,针对所观看的景观,
我们能获得效果很好的
3D 等距视图。
最后是摄像头缩放率。
这个数值越大,
您离地球表面就越近。
您可以想象摄像头缩放率为 0 的情况,
这时候我们所在的位置
就是摄像头高高在上的位置。
向下俯视地球。
如果摄像头缩放率为 17,
向下俯视的位置就非常接近地球。
您可以看到,由于
我将摄像头倾斜度设置成 65 度,
因此能获得纽约城摩天大楼的
3D 视图。
由于将摄像头缩放率设置为 17,
因此观看位置实际上
比其中某些摩天大楼的高度还低。
现在运行应用程序,
看一下运行效果怎么样。
现在,我们可以看到
应用程序在平板电脑上运行。
屏幕上显示纽约的市区视图,
我实际上可以来回滚动
并以三维方式查看城市。
我可以看到一些摩天大楼是
圆柱形的。
我之前说过,
实际上我们的观看位置
在帝国大厦的底部,在这里您可以看到
帝国大厦的最高点
已经在摄像头视野之外。
因为摄像头的位置实际上
低于该建筑的高度。
随着我对纽约城进行缩放与平移,
我们可以看一下
某些建筑的
有趣的特色。
例如,这是联合国总部,
可以眺望曼哈顿东河。
这是曼哈顿东河中的
某些小岛,
在摩天大楼上可以看到它们。
有时,需要花一点时间
才能显示。
现在您已经有效地免费
获得这些数据,
不需要进行任何设置,
就可以获得 3D 视图或与此类似的地图。
基本上,通过
倾斜摄像头并
尽量接近地面,
就能看到 3D 视图。
如果我拉远,您可以看到,
现在将显示纽约城的平面图,
没有 3D 效果。
在我拉远时,您可以看到,
我们面向东方,
面朝长岛。
再次拉近到城市,
只要足够近,我们就能看到
建筑与摩天大楼
拔地而起。
在这里。
非常简单,
只要设置地图片段的属性,
就可以获得所有这些功能。
这很酷,不是吗?