Graphic - 資料一線通

flosssnailsMobile - Wireless

Dec 10, 2013 (3 years and 10 months ago)

83 views

Data.One Campaign

「資料一線通」推廣運動

Introduction

Supported by

Office of the Government Chief Information
Officer, The Government of the HKSAR

Organizer:

Co
-
Organizer:

Project Title


Data.One Campaign

「資料一線通」推廣運動



Theme


Promoting Value
-
Added Re
-
use of Public
Section Information

Developing Location
-
based
Applications for PSI on

Course Outline


Introduction to Android



Public Sector Information (PSI)



Using PSI data with ArcGIS Online Map



Using PSI date with Google Map

Introduction to
Android



What is Android


Software platform from Google and the
Open Handset Alliance



Open software platform for mobile
development



Powered by Linux operating system


Versions of Android

Distribution

API

level

%

4.0
Ice Cream Sandwich

14
-
15

0%

3.x.x
Honeycomb

11
-
13

1.8%

2.3.x
Gingerbread

9
-
10

38.7%

2.2
Froyo

8

45.3%

2.1
Eclair

7

11.7%

1.6
Donut

4

1.4%

1.5
Cupcake

3

1.1%

Development Environments


Android SDK


Tools and APIs necessary to begin developing applications


Eclipse


Integrated development environment (IDE)


Android Development Tools (ADT)


Plug
-
in for Eclipse


*Exercise 1


Install driver for android phone



Create Android Virtual Machine



Run Application on Android devices


* Exercise documents will be distributed during the class

Public Sector Information (PSI)


What is PSI


demographic, economic, geographical and
metrological data owned by Government and public
bodies


Can be downloaded from
Data.One


http://www.gov.hk/tc/theme/psi/welcome/






demographic, economic, geographical and
metrological data owned by Government and public
bodies


Can be downloaded from
Data.One


http://www.gov.hk/tc/theme/psi/welcome/





PSI in Data.One


Referenced public facility data



Locations of government offices


Schools


Libraries


Leisure, cultural and sports facilities


Hospitals



Real
-
time traffic data



Raw data of traffic speed map


Journey time indicators


Special traffic news


Traffic snapshot images


*Exercise II


Use GeoInfo Map



Download PSI Data (Swimming Pool)


* Exercise documents will be distributed during the class

Using PSI data with ArcGIS Online
Map



ArcGIS API for Android


Includes a plug
-
in to the Eclipse



Build applications to


Display and navigate maps


Find addresses and places


Identify locations and GIS features


Measure lines and areas


Find and share maps from ArcGIS Online


Collect GIS data


Use your phones GPS



Developer Resources


ArcGIS for Android



Can download from the Android Market


Explore maps available from ArcGIS Online


Open and view rich map content, collect GIS features and
much more








Developer resources


ArcGIS for Android API Beta Program


http://resources.arcgis.com/content/arcgis
-
android/api



ArcGIS Resources Centers


http://resources.arcgis.com/


Data
,
Code galleries
,
Samples and tutorials



ESRI Developer Network (EDN)


http://www.esri.com/edn


Developer licenses and supports discounts


Map Layers


Layer types

in ArcGIS API for

Android


T
iled layers



D
ynamic layers


Feature layers



Tiled layers provide much

better
p
erformance than

dynamic layers





Tiled Map Layers


Tiled Map hosted by
ArcGIS Server
:




World Topographic Map

http://server.arcgisonline.com/ArcGIS/r
est/services/World_Topo_Map/MapSer
ver






World Imagery Map

http://server.arcgisonline.com/ArcGIS/r
est/services/World_Imagery/MapServer







World Street Map

http://server.arcgisonline.com/ArcGIS/r
est/services/World_Street_Map/MapSer
ver

Add Tiled Map to the App

Method 1. Define the map in Layout File

Method 2. Dynamically add the map in Java

Map Extent of the world

Method 2. Dynamically

http://help.arcgis.com/en/webapi/flex/samples/index.html#/Map_Extent_and_Mo
use_Coordinates/01nq0000002w000000/


Map Extent of Hong Kong

http://help.arcgis.com/en/webapi/flex/samples/index.html#/Map_Extent_and_Mo
use_Coordinates/01nq0000002w000000/


Add Tiled Map to the App

Method 1. Define the map extent in Layout File

initExtent="
12669938.691849

2515999.206207

12736867.651545

2612209.588660
"

Method 2. define the extent in program Dynamically

What is

G
raphics
L
ayer


Graphic = geometry + attributes +
symbols


Rich symbolization


Points, lines & polygons


Pictures

Create Graphic Layer and add Point Graphic


Add Graphic Layer to map


map = (MapView) findViewById(R.id.
map
);


graphicsLayer

=
new

GraphicsLayer(
this
);


map.addLayer(graphicsLayer);


Graphic

=
G
eometry

+
A
ttributes

+
S
ymbols


Graphic


Graphic myGraphic =
new

Graphic();


G
eometry


Point myPoint =
new

Point(); myPoint.setXY(X, Y);



myPoint = (Point) GeometryEngine.
project
(myPoint,SpatialReference.
create
(2326), SpatialReference.
create
(102100));


myGraphic.setGeometry(myPoint)


A
ttributes


graphic.addAttribute(“Hello", "ABC");


S
ymbols


SimpleMarkerSymbol mySMS =
new

SimpleMarkerSymbol(Color.
GREEN
, 20, STYLE.
DIAMOND
)


myGraphic.setSymbol(
mySMS
)


Add Graphic to the Graphic Layer


graphicsLayer.addGraphic(myGraphic);


Geometry Engine and Geometry Service


Convert coordinate system from one to another one



myPoint = (Point)
GeometryEngine.project(myPoint,SpatialReference.create(
2326
),
SpatialReference.create(
102100
));


2326:


Hong_Kong_1980_Grid (PSI DATA)

102100:


WGS_1984_Web_Mercator_Auxiliary_Sphere (ArcGIS Online
Map)

Reference:

http://help.arcgis.com/EN/arcgisserver/10.0/apis/rest/pcs.html

Graphic Info Template


Show information when
user click the graphic
interface

Current Location


D
evice's location

can
retrieve

from



Wi
-
Fi, cellular networks, or GPS

*Exercise III


Create ArcGIS Online Map
Application



Working with PSI Data

* Exercise documents will be distributed during the class

Using PSI data with Google Map



Google Maps API


Integration between Android
applications and Google Maps



Add Google API to Eclipse SDK





Google Maps API Key



Required in order to use Google Maps API



Obtaining a Map API Key:


http://code.google.com/intl/zh
-
HK/android/add
-
ons/google
-
apis/mapkey.html



Define the key in Layout file



Extends the MapActivity


To extend from
MapActivity

we have to implement the
isRouteDisplayed

method, which denotes whether or not we
are displaying any kind of route information, such as a set
of driving directions. We will not provide such information,
so we just return false there.


Map Controller


A utility class for managing panning and
zooming of a map


Used to zoom to Hong Kong




Overlay Item



Create your own map markers and lay
-
overs



Current Location



Location Manager


Access to the system location services.


Obtain periodic updates of the device's geographical location


*Exercise IV


Create Google Map Application



Working with PSI Data


* Exercise documents will be distributed during the class