2. Flow – Loading (Use as GoogleAPI as
reference)
Initialize
Select title’s source
Inject Auth key
mapOption for setting default zoom, center, and ON/OFF for the default UI like panControl and
zoomControl and mapTypeControlOptions and zoomControlOptions
create an array of styles (if using own tile, this happens in beckend)
Markers and infowindow
Create an array of data for marker, infowindow
Instance latlng object with geo data above
Custom UI image settings like Anchor, origin, url , size, shape for marker and infowindow
Instance marker and infowindow object
setMarker(map, location)
Add listener for marker’s click in order to show infowindow
loading the map (binding to DOM)
google.maps.event.addDomListener(window, 'load', initialize)
3. Flow – Loading (Use as GoogleAPI as
reference)
• UI control
• Default UI
• ON/OFF and Position
• Put oogle.maps.ControlPosition.BOTTOM_CENTER in mapTypeControlOptions
and zoomControlOptions
• Custom UI
• Create DOM element for INPUTs ( state and method)
• Give them the UI settings like backgroundColor, border
• Add listener for DOM region for designated acton
• Position it in map by ex.
map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(centerCon
trolDiv)
4. Flow – Loading (Use as GoogleAPI as
reference)
• Layer from KML, GeoJSON for line, polygon
• Load from URL or local side
• Feed the setting of feature style
• Add listener for the event ex. Static or dynamic (mouseover for
one style and mouseout for another style)
• In google, by revertStyle();;map.data.setStyle
6. Custom MAP looks - Styled Maps
Native support in MAP v3
https://developers.google.com/maps/customize?hl=zh-tw
Styled Maps Wizard native support in MAP v3
http://gmaps-samples-
v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html
However Android MAP V2 doesn’t support it and we may use TileOverlay ONLY
http://stackoverflow.com/questions/16520121/customize-color-scheme-of-
google-maps-v2-in-android
https://developers.google.com/maps/documentation/android/tileoverlay
https://developer.android.com/reference/com/google/android/gms/maps/mo
del/TileOverlay.html
7. Basic flow (JavaScript V3) – 1
同步方式載入 API
取得 API 金鑰
使用 script 標記來加入 Maps API JavaScript。
建立 div 元素 (名稱為「map_canvas」) 來容納「地圖」
Declare mapOtions for the settings like center and zoom
New google.maps.Map with the assignned UI id
Perform in onload 事件
非同步方式載入 API
https://developers.google.com/maps/documentation/java
script/examples/map-simple-async?hl=zh-tw
8. Basic flow (JavaScript V3) - 2
營利性網站可以使用 Google Maps JavaScript API 第 3 版,每日最多載入 25,000 次地圖。只要地圖
在網頁上完成初始化作業,系統就會計算一次地圖載入。地圖載入之後,使用者與地圖的互動 (例如,
移動地圖、縮放地圖,或將道路圖變更為衛星圖) 並不會影響使用限制。
如果您經營的營利性網站每天持續超過 Maps API 使用限制,就必須採用以下其中一種因應方法:
透過 Google API 控制台購買額外配額。
購買 Google Maps API for Business 授權。
修改網站,讓使用量降到限額以下。
13. Basic flow (JavaScript V3) - 8
FIRST請於建構時在地圖的 MapOptions 中設定樣式陣列,或者呼叫 setOptions
var styles = [{featureType: '', elementType: '',stylers: [{hue: ''},{saturation:
''},{lightness: ''}]]
map.setOptions({styles: styles});
OR
需建立 StyledMapType,然後將地圖項和樣式工具資訊傳送至建構函式
var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
14. Basic flow (JavaScript V3) - 9
google.maps.MapTypeStyleFeatureType object specification
https://developers.google.com/maps/documentation/javascript/referenc
e?hl=zh-tw#MapTypeStyleFeatureType
Constant Description
administrative Apply the rule to administrative
areas.
administrative.country Apply the rule to countries.
administrative.land_parcel Apply the rule to land parcels.
administrative.locality Apply the rule to localities.
administrative.neighborhood Apply the rule to neighborhoods.
administrative.province Apply the rule to provinces.
Constant
15. Basic flow (JavaScript V3) - 10
Styled Maps Wizard
http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html
The Site to provide lots of the example of styled map.
https://snazzymaps.com/style/131/mondrian
BTW, the author’s introduction site is brilliant
http://leethree.me/