We saw earlier that we could add
a map fragment or a layout file and
set properties on it to get some
pretty interesting and cool maps.
We even had a 3D fly over of New York
city that was pretty cool right?
Well that just scratches
the surface of the types of app
that you can build with map integration.
The XML based maps always
start in the same location and
that can be limiting for a mobile app.
So in order to get
a little more power and
flexibility, we're going to switch gears
and start using the Google Map objects
to compliment the map
fragment using Java code.
Once we've gotten that, it then becomes
really easy to set properties and
respond to user events on the map.
Let's start with an example where
we set the different map types
such as the standard map,
the satellite view or the hybrid view.
In this app,
you can see a map of New York City.
And I have control
over this map by touch.
I can panoram the map, and as you can
see, I can pinch to zoom in and out.
When I press the buttons at the top
of the map, Map, Satellite and
Hybrid, I can change the map type.
So if I touch Satellite,
I now can see details of the buildings
taken from Satellite images.
Here you can see Madison Square Garden
and even when I zoom in I can
begin to see some of the seating
plans in Madison Square Garden.
And of course Hybrid gives
me a hybrid of the two.
I can see satellite but
I can also see data such as landmarks
like the Empire State Building and
street names such as Fifth Avenue,
as you can see here.
I've done all of this using a Google
map object in my Java code.
This is slightly different
from the fragment that
you used in the earlier sample.
And we're going to dive in to take
a look at how to do this next.
شاهدنا سابقًا أنه يمكننا إضافة
جزء من خريطة، أو ملف تخطيط
وتعيين خصائص عليه؛ للحصول على بعض
الخرائط المثيرة للاهتمام، والممتعة.
كما قمنا بجولة ثلاثية الأبعاد فوق نيويورك
والتي كانت رائعة، أليس كذلك؟
حسنًا هذا مجرد مسح
للسطح لأنواع التطبيق
التي يمكنك إنشاؤها بتكامل
الخريطة.
ودائمًا ما تبدأ الخرائط المستندة لـ XML
في الموقع نفسه
الذي يمكن أن يكون محدودًا في التطبيق المحمول
لذلك؛ من أجل الحصول على
قدرة أكثر من ذلك بقليل
ومرونة، سنقوم بتبديل الأمور
وبدء استخدام كائنات Google Map؛
لاستكمال جزء الخريطة
باستخدام رمز جافا.
بمجرد الوصول لذلك، يصبح
من السهل بالفعل تعيين خصائص
الرد على أحداث المستخدم على الخريطة.
لنبدأ بمثال يمكّننا من
وضع أنواع مختلفة للخرائط
مثل الخريطة القياسية،
عرض القمر الصناعي، أو العرض المختلط.
في هذا التطبيق،
يمكنك أن ترى خريطة نيويورك.
أستطيع التحكم
في هذه الخريطة باللمس
أستطيع عرض الخريطة بشكل بانورامي، وكما
ترى، يمكنني التكبير والتصغير.
عند الضغط على الأزرار أعلى
الخريطة، الخريطة والقمر الصناعي
المختلط، يمكنني تغيير نوع الخريطة.
سألمس زر القمر الصناعي،
الآن، أستطيع أن أرى تفاصيل المباني
بصور الأقمار الصناعية.
فهنا ترى حديقة ماديسون سكوير،
حتى عندما أقوم بالتكبير يمكنني
أن أبدأ في رؤية بعض تخطيطات
المقاعد في حديقة ماديسون سكوير.
وبالطبع يعطيني وضع الهجين
مزيجًا من الاثنين.
أستطيع رؤية وضع القمر الصناعي، ولكن
أستطيع أن أرى أيضًا بيانات مثل معالم؛
كمبنى إمباير ستيت
أسماء الشوارع مثل: الشارع الخامس،
كما ترون هنا.
لقد فعلت كل هذا باستخدام كائن Google
map برمز جافا.
وهذا يختلف قليلاً
عن الجزء الذي
استخدمته في العينة السابقة.
نحن في طريقنا للتوغل أكثر؛ لإلقاء نظرة
على كيفية القيام بذلك فيما يلي:
Nós vimos mais cedo, que podemos adicionar
um fragmento de mapa ou um arquivo de layout
e definir propriedades para ele
a fim de obter alguns mapas
muito interessantes e úteis.
Nós tínhamos até mesmo um voo em 3D
sobre a cidade de Nova York,
que era bastante interessante, certo?
Pois ele nem de leve se aproxima
dos tipos de aplicativo
que você pode criar
com integração de mapas.
Os mapas baseados em XML sempre
começam na mesma localização
e isso pode ser limitante
para um aplicativo móvel.
Assim, para conseguir um pouco mais
de poder e flexibilidade,
vamos trocar o mecanismo
e começar a usar
os objetos do Google Map,
para complementar
o fragmento de mapa usando código Java.
Uma vez de posse disso, fica
realmente fácil
definir propriedades
e responder aos eventos
de usuário no mapa.
Vamos começar com um exemplo no qual
definimos diferentes tipos de mapa
tais como o mapa padrão,
a visão de satélite
ou a visão híbrida.
Neste aplicativo, você pode ver
um mapa de Nova York.
E posso controlá-lo
com o toque.
Posso abrir o mapa,
e como você vê,
é possível interagir para aplicar mais ou menos zoom.
Quando pressiono os botões na parte superior
do mapa, Map, Satellite
e Hybrid, posso mudar
o tipo de mapa.
Assim, se toco em Satellite,
posso ver
detalhes dos prédios,
que foram obtidos de imagens de satélite.
Aqui você pode ver o Madison Square
Garden, e quando aumento o zoom,
começo a ver parte do mapa de assentos
do Madison Square Garden.
Hybrid, como o nome sugere, fornece
uma mistura dos dois.
É possível ter a visão de satélite,
mas também de pontos de referência
como o Empire State Building,
e nomes de ruas como a Quinta
Avenida, que você vê aqui.
Fiz tudo isso usando um objeto
Google Map
em meu código Java.
Isso é ligeiramente diferente
do fragmento
que você usou
no exemplo anterior.
Em seguida, vamos entrar nos detalhes
para examinar
como fazemos isso.
我们之前已经看到,
可以添加地图片段或布局文件
并设置其属性,从而获得
非常有趣、非常酷的地图。
我们甚至还制作了飞越纽约城
的 3D 地图,非常酷,不是吗?
对于使用地图整合可以建置的
应用类型来说,这些只是
很浅显的应用。
XML 式地图都
采用这种方法,而且
仅限于移动应用。
为了获得
更多的功能与
更高的灵活性,我们接下来将转换
方式,开始使用 Google Map 对象
对使用 Java 代码
开发的地图片段进行补充。
了解这些内容后,就可以很轻松地
设置属性并
在地图上响应用户事件。
接下来首先我们会展示示例,
在其中我们会设置不同的地图类型,
例如标准地图、
卫星视图或混合视图。
在这款应用中,
您会看到纽约城的地图。
我通过触摸方式
来控制该地图。
我可以看到地图全景,您可以看到,
我也能通过夹捏实现拉近与拉远。
如果按下地图顶部的按钮
“地图”、“卫星”
与“混合”,可以更改地图类型。
如果触摸“卫星”,
现在可以看到从卫星图像中
提取的建筑细节。
在这里您可以看到麦迪逊广场花园,
在我拉近时,甚至能看到
麦迪逊广场花园的
一些座位排列。
当然,混合视图
能提供两者的混合。
我能看到卫星视图,
也能看到数据,
例如帝国大厦等地标,
以及第五大道等街道名称,
在这里您可以看到。
我在 Java 代码中使用 Google map 对象
来实现所有这些功能。
这与您在之前的示例中
所用的片段
稍有不同。
接下来我们将深入探讨
如何实现这些功能。