1. Trang chủ
  2. » Công Nghệ Thông Tin

Beginning Google Maps Applications with PHP and Ajax From Novice to Professional PHẦN 10 ppt

32 399 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Beginning Google Maps Applications With PHP And Ajax From Novice To Professional Phần 10 Ppt
Trường học Unknown
Chuyên ngành Google Maps Applications
Thể loại Tài liệu
Năm xuất bản 2006
Thành phố Unknown
Định dạng
Số trang 32
Dung lượng 320,29 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

GOverlay Static Method Static Method Returns Description getZIndexlatitude Number Returns the CSS z-index value for the given latitude.. isHidden Boolean Returns true if the info window

Trang 1

Method Returns Description

centered on the given GLatLng

getInfoWindow() GInfoWindow Returns the info window object of this map If no

info window exists, it is created but not displayed

enableInfoWindow()does not affect the result ofgetInfoWindow()

Coordinate Transformations

fromLatLngToDivPixel(latlng) GPoint Returns the GPointpixel coordinates of

the given GLatLnggeographical location,relative to the DOM element that containsthe draggable map

fromDivPixelToLatLng(pixel) GLatLng Returns the GLatLnggeographical

coordinates of the given GPointpixelcoordinates, relative to the DOM elementthat contains the draggable map

fromContainerPixelToLatLng(pixel) GLatLng Returns the GLatLnggeographical

coordi-nates of the given GPointpixelcoordinates, relative to the DOM elementthat contains the map on the page

Events

addmaptype maptype Fired when a map type is added to the map using

addMapType().removemaptype maptype Fired when a map type is removed from the map

using removeMapType().click overlay, latlng Fired when the map is clicked with the mouse If the

click is on aGOverlayobject such as a marker, theoverlay is passed to the event handler through theoverlayargument and the overlay’s clickevent isfired If no overlay is clicked, the GLatLnglocation ofthe click is passed in the latlngargument

fire when dragging the map with the mouse, inwhich case adragstartis also fired, or by invokingthe movement using one of the GMapmethods

fire repeatedly as the map moves

zoomend oldLevel, newLevel Fired when the map reaches a new zoom level

Trang 2

Event Arguments Description

infowindowclose Fired when the info window closes If a currently

open info window is reopened at a different pointusing another call to openInfoWindow*(), theninfowindowclosewill fire first

addoverlay overlay Fired when an overlay is added using addOverlay()

The overlay is passed to the event handler

removeoverlay overlay Fired when a single overlay is removed by the

method removeOverlay() The overlay that wasremoved is passed as an argument to the eventhandler

clearOverlays()

outside the map AGLatLnglocation is passed tothe event handler

AGLatLnglocation is passed to the event handler

map This event is repeatedly fired while the usermoves around the map AGLatLnglocation ispassed to the event handler

with the exception of the image tiles, which loadasynchronously

class GMapOptions

The GMapOptions class, instantiated as an object literal, is used to provide optional arguments

to the GMap class constructor

GMapOptions Properties

size GSize Sets the size of the map container If the container is of

a different size, the container will be resized to the givenGSize If no size is passed, the map will assume the currentsize of the container

mapTypes Array of GMapType Array of GMapTypeconstants to allow for the map If no

mapTypesare defined, the constant G_DEFAULT_MAP_TYPES

is used See also GMap2.addMapType()

enum GMapPane

As discussed in Chapter 9, the GMapPane constants define the various layers of the map used toplace overlays and their complementary icons and shadows

Trang 3

GMapPane Constants

G_MAP_MAP_PANE The bottom layer, directly on top of the map Used to hold

overlays such as polylines

G_MAP_MARKER_SHADOW_PANE The pane containing the shadow of the markers Lies

directly beneath the markers

G_MAP_MARKER_PANE The pane containing the markers

G_MAP_FLOAT_SHADOW_PANE The pane containing the shadow of the info window It lies

above the G_MAP_MARKER_PANEto allow the markers toappear in the shadow of the info window

G_MAP_MARKER_MOUSE_TARGET_PANE The pane that holds transparent objects that react to the

DOM mouse events registered on the overlays It lies abovethe G_MAP_FLOAT_SHADOW_PANEto allow all the markers on themap to be clickable, even if they lie in the shadow of the infowindow

G_MAP_FLOAT_PANE The topmost layer This pane contains any overlays that

appear above all others but under the controls, such as theinfo window

class GKeyboardHandler

You can instantiate a GKeyboardHandler to add your own keyboard bindings to a map

GKeyboardHandler Bindings

up, down, left, right Continuously moves the map while the key is pressed If two

nonopposing keys are pressed simultaneously, the map willmove diagonally

page down, page up, home, end Triggers an animated pan by three-quarters of the height or

width in the corresponding direction

+, - Adjusts the zoom level of the map by one level closer (+) or

As discussed in detail in Chapters 7 and 9, the GOverlay interface is implemented by the

GMarker, GPolyline, and GInfoWindow classes, as well as any custom overlays you create The

GOverlayinstance must be attached to the map using the GMap2.addOverlay() method Upon

addition, the map will call the GOverlay.initialize() method Whenever the map display

changes, the map will call GOverlay.redraw()

Trang 4

GOverlay Constructor

Constructor Description

GOverlay() Creates the default implementation of the GOverlaymethods and should be used

when inheriting from the class

GOverlay Static Method

Static Method Returns Description

getZIndex(latitude) Number Returns the CSS z-index value for the given latitude By

default, overlays that are farther south have higher z-indexvalues, so that the overlays will appear stacked when closetogether

GOverlay Abstract Methods

initialize(map) Called by GMap2.addOverlay()so the overlay can draw itself

into the various panes of the map

remove() Called by GMap2.removeOverlay()and GMap2.clearOverlays()

The overlay should use this method to remove itself from themap

copy() GOverlay Returns an uninitialized copy of itself

redraw(force) Called when the map display changes forcewill be true only if

the zoom level or the pixel offset of the map view has changed

class GInfoWindow

GInfoWindowis always created by the GMap or GMarker class and accessed by their methods

GInfoWindow Methods

selectTab(index) Selects the tab with the given index

remove it from the map

invisible

isHidden() Boolean Returns true if the info window is hidden or closed.reset(latlng, tabs, size, Resets the state of the info window to the given [offset], [selectedTab]) arguments If the argument value is null, that item

will maintain its current value

getPoint() GLatLng Returns the geographical point at which the info

window is anchored The default info window points

to this point, modulo the pixel offset

getPixelOffset() GSize Returns the offset, in pixels, of the tip of the info

window from the anchor point

getSelectedTab() Number Returns the index of the selected tab The first

left-most tab is index 0

Trang 5

GInfoWindow Event

closeclick Fired when the info window’s close button (X) is clicked

class GInfoWindowTab

Instances of GInfoWindowTab are passed as an array to the tabs argument of GMap2

openInfoWindowTabs(), GMap2.openInfoWindowTabsHtml(), GMarker.openInfoWindowTabs(), and

GMarker.openInfoWindowTabsHtml()

GInfoWindowTab Constructor

GInfoWindowTab(label, content) Creates a tab object that can be passed to the tabs

argu-ment for all openInfoWindowTabs*()methods The label

is the text that appears on the tab The contentcan beeither an HTML string or a DOM node, depending onwhich openInfoWindowTabs*()method you plan to use

class GInfoWindowOptions

The GInfoWindowOptions class, instantiated as an object literal, is used to provide optional

arguments for the GMap and GMarker methods: openInfoWindow(), openInfoWindowHtml(),

openInfoWindowTabs(), openInfoWindowTabsHtml(), and showMapBlowup()

GInfoWindowOptions Properties

selectedTab Number Sets the window to open at the given tab The first leftmost tab is

index 0 By default, the window will open on tab 0

maxWidth Number Maximum width, in pixels, of the info window content

onOpenFn Function Called after the info window has finished opening and the content

is displayed

onCloseFn Function Called when the info window has been closed

zoomLevel Number Applies only when using showMapBlowup() The zoom level of the

blowup map in the info window

mapType GMapType Applies only when using showMapBlowup() The map type of the

blowup map in the info window

class GMarker

An instance of the GMarker class is used to mark a geographical location on a map It implements

the GOverlay interface and is added to the map using the GMap2.addOverlay() method

Trang 6

openInfoWindow Opens the info window over the icon of the marker (content, [opts]) The contentof the info window must be defined using

a DOM node Optional arguments are passed usingthe GInfoWindowOptionsclass

openInfoWindowHtml Opens the info window over the icon of the marker (content, [opts]) The contentof the info window must be defined using

a string of HTML Optional arguments are passedusing the GInfoWindowOptionsclass

openInfoWindowTabs Opens the tabbed info window over the icon of the

defined as an array of GInfoWindowTabinstances thatcontain the tab content as DOM nodes Optionalarguments are passed using the GInfoWindowOptionsclass

openInfoWindowTabsHtml Opens the tabbed info window over the icon of the

defined as an array of GInfoWindowTabinstances thatcontain the tab content as a string of HTML Optionalarguments are passed using the GInfoWindowOptionsclass

showMapBlowup([opts]) Opens the info window over the icon of the marker

The content of the info window becomes a close-up ofthe area around the info window’s anchor Optionalarguments are passed using the GInfoWindowOptionsclass

getIcon() GIcon Returns the GIconassociated with this marker as

defined in the constructor

getPoint() GLatLng Returns the GLatLnggeographical coordinates of the

marker’s anchor The anchor is set by the constructor

or modified by setPoint().setPoint(latlng) Sets the geographical coordinates of the marker’s

anchor to the given GLatLnginstance

GMarker Events

GMap’s clickevent will also fire with the marker passed

as the overlay argument

marker icon

Trang 7

Event Arguments Description

icon

marker icon

infowindowopen Fired when the info window of the map is opened using

one of the GMarkerinfo window methods

infowindowclose Fired when the info window, opened using

GMarker.OpenInfoWindow*(), is closed or if the infowindow is opened on another marker

class GMarkerOptions

The GMarkerOptions class, instantiated as an object literal, is used to provide optional

argu-ments for the GMarker class

GMarkerOptions Properties

icon GIcon An instance of the GIconclass If not specified, G_DEFAULT_ICONis used

clickable Boolean If set to false, the marker becomes inert and consumes fewer

resources Inert markers will not respond to any events By default,this option is true and markers are clickable

title String The title will appear as a tool tip on the marker, like the titleattribute

on HTML elements

class GPolyline

If available, the GPolyline class draws a polyline on the map using the browser’s built-in

vector-drawing facilities Otherwise, the polyline is drawn using an image from Google servers

GPolyline Constructor

GPolyline(points, [color], Creates a polyline from the array of GLatLnginstances

Option-[weight], [opacity]) ally, the colorof the line can be defined as a string in the

hexa-decimal format RRGGBB; the weightcan be defined in pixels;

and the opacitycan be defined as a number between 0and 1,where 0is transparent and 1is opaque

GPolyline Methods

getVertexCount() Number Returns the number of vertices in the polyline

getVertex(index) GLatLng Returns the vertex with the given indexin the polyline

starting at 0 for the first vertex

Trang 8

GPolyline Event

Event Arguments Description

class GIcon

The GIcon class specifies the image to display as the icon for the GMarker on the map If no icon

is specified, G_DEFAULT_ICON is used

GIcon Constructor

GIcon([copy], [image]) Creates a new GIconobject Existing GIcon’s properties can be copied

by passing the existing icon into the copyargument The optionalimageargument can be used as a shortcut to the imageproperty

GIcon Constant

G_DEFAULT_ICON The default icon used by markers

GIcon Properties

iconSize GSize The pixel size of the foreground image

shadowSize GSize The pixel size of the shadow image

iconAnchor GPoint The pixel coordinates of the image’s anchor relative to the

top-left corner of the image

infoWindowAnchor GPoint The pixel coordinates of the point where the info window

will be anchored, relative to the top-left corner of the image.printImage String URL of the foreground image used for printed maps It must

be the same size as the imageproperty

mozPrintImage String The URL of the foreground icon image used for printed maps in

Firefox/Mozilla It must be the same size as the imageproperty.printShadow String The URL of the shadow image used for printed maps Most

browsers can’t accurately print PNG transparency, so thisproperty should be a GIF

Trang 9

Property Type Description

transparent String Used to represent the clickable part of the icon in Internet

Explorer This should be a URL to a 24-bit PNG version of themain icon image with 1% opacity and the same shape andsize as the imageproperty

imageMap Array of Used to represent the clickable part of the icon in browsers

numbers other than Internet Explorer This should be an array of integers

representing the X/Y coordinates of the clickable image area

class GPoint

In version 1 of the API, a GPoint represented a geographical latitude and longitude In version 2

of the API, a GPoint represents a point on the map by its pixel coordinates Now, for

geographi-cal latitude and longitude, see the GLatLng class

Unlike regular HTML DOM elements, the map coordinates increase to the left and down,

so the X coordinate increases as objects are farther west, and the Y coordinate increases as

objects are farther south

Note Although the xand yproperties are accessible and modifiable, Google recommends you always

create a new GPointinstance and avoid modifying an existing one

GPoint Constructor

Constructor Description

GPoint(x, y) Creates aGPointobject

GPoint Properties

Property Type Description

x Number X coordinate, increases to the left

y Number Y coordinate, increases downwards

GPoint Methods

equals(other) Boolean Returns true if the other given GPointhas equal coordinates

toString() String Returns a string that contains the X and Y coordinates, separated

by a comma and surrounded by parentheses, in the form (x,y)

class GSize

A GSize is a width and height definition, in pixels, of a rectangular area on the map Note that

although the width and height properties are accessible and modifiable, Google recommends

that you always create a new GSize instance and avoid modifying an existing one

Trang 10

GSize Constructor

GSize(width, height) Creates aGSizeobject

GSize Properties

Property Type Description

width Number The width in pixels

height Number The height in pixels

GSize Methods

equals(other) Boolean Returns true if the other given GSizehas exactly equal

components

toString() String Returns a string that contains the width and height

coordi-nates, separated by a comma and surrounded by parentheses,

in the form (width,height)

Property Type Description

minX Number The X coordinate of the left edge of the rectangle

minY Number The Y coordinate of the top edge of the rectangle

maxX Number The X coordinate of the right edge of the rectangle

maxY Number The Y coordinate of the bottom edge of the rectangle

GBounds Methods

toString() String Returns a string containing the northwest and the

southeast corners of the area separated by a comma,surrounded by parentheses, in the form (nw,se).min() GPoint The point at the upper-left corner of the box

Trang 11

Method Returns Description

max() GPoint The point at the lower-right corner of the box

containsBounds(other) Boolean Returns true if the other GBoundsis entirely contained in

this GBounds.extend(point) Increases the size of the bounds so the given GPointis

also contained in the bounds

intersection(other) GBounds Returns a new GBoundsobject that represents the

over-lapping portion of this and the givenGBounds

class GLatLng

A GLatLng instance represents a geographical longitude and latitude on the map projection

Note Although longitude is representative of an X coordinate on a map, and latitude with the Y coordinate,

Google has chosen to follow customary cartography terminology where the latitude coordinate is written

first, followed by the longitude as represented in the GLatLngconstructor arguments

GLatLng Constructor

GLatLng(lat, lng, [unbounded]) Creates a new GLatLnginstance If the unboundedflag is

true, the latitude and longitude will be used as passed

Otherwise, latitude will be restricted to between -90degrees and +90 degrees, and longitude will be wrapped tolie between -180 degrees and +180 degrees

GLatLng Methods

lat() Number Returns the latitude coordinate in degrees

latRadians() Number Returns the latitude coordinate in radians, as a number

between -PI/2 and +PI/2

lngRadians() Number Returns the longitude coordinate in radians, as a number

between -PI and +PI

equals(other) Boolean Returns true if the other GLatLnghas equal components

(within an internal round-off accuracy)

distanceFrom(other) Number Returns the distance, in meters, from this GLatLngto the

other GLatLng Google’s API approximates the earth as

a sphere, so the distance could be off by as much as 0.3%

toUrlValue() String Returns a string representation of this point that can be

used as a URL parameter value The string is formatted withthe latitude and the longitude in degrees rounded to sixdecimal digits, separated by a comma, without whitespace

Trang 12

GLatLng Properties

There are a few GLatLng properties; however, they exist only for backward-compatibility withversion 1 of the API Therefore, we do not list them here If you would like to reference them,see Google’s online documentation at http://www.google.com/apis/maps/documentation/reference.html#GLatLng

GLatLngBounds([sw], [ne]) Creates a new instance of GLatLngBoundswith a boundary

defined by the southwest and northeast corners

GLatLngBounds Methods

equals(other) Boolean Returns true if the other GLatLngBoundshas equal

components (within an internal round-off accuracy).contains(latlng) Boolean Returns true if the geographical coordinates of the

given GLatLnglie within the boundary

intersects(other) Boolean Returns true if the given GLatLngBoundsintersects this

GLatLngBounds.containsBounds(other) Boolean Returns true if the given GLatLngBoundsis contained

entirely within this GLatLngBounds.extend(latlng) Increases the size of the bounds so the given GLatLng

is also contained in the bounds When calculating thelongitude change, the bounds will enlarged in thesmaller of the two possible ways given the wrapping ofthe map If both directions are equal, the bounds willextend at the eastern boundary

getSouthWest() GLatLng Returns the latitude and longitude at the southwest

corner of the rectangle

getNorthEast() GLatLng Returns the latitude and longitude at the northeast

corner of the rectangle

toSpan() GLatLng Returns aGLatLngwith latitude and longitude degrees

representing the height and width, respectively.isFullLat() Boolean Returns true if this boundary extends the full height of

the map, from the south pole to the north pole.isFullLng() Boolean Returns true if this boundary extends fully around the

earth

isEmpty() Boolean Returns true if this boundary is empty

getCenter() GLatLng Returns the center point of the rectangle

Trang 13

interface GControl

As discussed in Chapter 9, the GControl interface is implemented by all control objects, and

implementations must be added to the maps using the GMap2.addControl() method

GControl Constructor

GControl([printable], [selectable]) Creates the prototype instance for a new control

class If the printableflag is true, the control willappear when printed Use the selectableargument

to indicate if the control contains text that should beselectable

GControl Methods

printable() Boolean Returns true to the map if the control should

be printable; otherwise, returns false

selectable() Boolean Returns true to the map if the control contains

selectable text; otherwise, returns false

initialize(map) Node Will be called by GMap2.addControl()so the

control can initialize itself and attach itself tothe map container

getDefaultPosition() GControlPosition Returns to the map the GControlPosition

rep-resenting where the control appears by default

This can be overridden by the second argument

GSmallMapControl() Creates a control with buttons to pan in four directions, and zoom in

and zoom out

GLargeMapControl() Creates a control with buttons to pan in four directions, and zoom in

and zoom out, and a zoom slider

GSmallZoomControl() Creates a control with buttons to zoom in and zoom out

GScaleControl() Creates a control that displays the map scale

GMapTypeControl() Creates a control with buttons to switch between map types

class GControlPosition

The GControlPosition class describes the position of a control in the map container A corner

from one of the GControlAnchor constants and an offset relative to that anchor determine the

position

Trang 14

GControlAnchor Constants

G_ANCHOR_TOP_RIGHT Anchored in the top-right corner of the map

G_ANCHOR_TOP_LEFT Anchored in the top-left corner of the map

G_ANCHOR_BOTTOM_RIGHT Anchored in the bottom-right corner of the map

G_ANCHOR_BOTTOM_LEFT Anchored in the bottom-left corner of the map

class GMapType

As discussed in Chapter 9, the GMapType is the grouping of a map projection and tile layers

GMapType Constructor

GMapType(layers, projection, name, [opts]) Creates a new GMapTypeinstance with the

given layer array of GTileLayers, the givenGProjection, a name for the map type con-trol, and optional arguments from

GMapTypeOptions

GMapType Methods

getSpanZoomLevel Number Returns the zoom level at which the GLatLng(center, span, viewSize) span, centered on the GLatLng center, will fit

in the GSizedefined by viewSize

(latlngBounds, viewSize) GLatLngBoundswill fit in the GSizedefined

by viewSize.getName(short) String Returns the name of the map type If shortis

true, the short name will be returned;otherwise, the full name will be returned.getProjection() GProjection Returns the GProjectioninstance

getTileSize() Number Returns the tile size in pixels The tiles are

assumed to be quadratic, and all tile layershave the same tile size

Trang 15

Method Returns Description

getTileLayers() Array of Returns the array of tile layers

GTileLayergetMinimumResolution Number Returns the lowest zoom level

([latlng])

getMaximumResolution Number Returns the highest zoom level

([latlng])

getTextColor() String Returns the color that should be used for text,

such as the copyright, overlaid on the map

getLinkColor() String Returns the color that should be used for

a hyperlink overlaid on the map

getErrorMessage() String Returns the error message to display on

zoom level where this map type doesn’t haveany map tiles

getCopyrights Array of strings Returns the copyright messages appropriate

given zoom level

parameter value to identify this map type inthe current map view Useful for identifyingmaps and returning to the same location viahyperlinks in web applications

GMapType Constants

G_NORMAL_MAP The normal street map type

G_SATELLITE_MAP The Google Earth satellite images

G_HYBRID_MAP The transparent street maps over Google Earth satellite images

G_DEFAULT_MAP_TYPES An array of G_NORMAL_MAP, G_SATELLITE_MAP, and G_HYBRID_MAP

GMapType Event

newcopyright copyright Fired when a new GCopyrightinstance is added to

the GCopyrightCollectionassociated with one ofthe tile layers contained in the map type

class GMapTypeOptions

The GMapTypeOptions class, instantiated as an object literal, is used to provide optional

argu-ments for the GMapType constructor

Trang 16

GMapTypeOptions Properties

shortName String The short name that is returned from GMapType.getName(true)

The default is the same as the name from the constructor.urlArg String The URL argument that is returned from GMapType.getUrlArg()

The default is an empty string

maxResolution Number The maximum zoom level The default is the maximum from all

tile layers

minResolution Number The minimum zoom level The default is the minimum from all

tile layers

tileSize Number The tile size for the tile layers The default is 256

textColor String The text color returned by GMapType.getTextColor() The

default is "black".linkColor String The text color returned by GMapType.getLinkColor() The

default is "#7777cc".errorMessage String The error message returned by GMapType.getErrorMessage()

The default is an empty string

GTileLayer Methods

minResolution() Number Returns the lowest zoom level for the layer

maxResolution() Number Returns the highest zoom level for the layer

getTileUrl(tile, zoom) String Abstract, must be implemented in custom tile layers

Returns the URL of the map tile tileis aGPointrepresenting the x and y tile index zoomis the currentzoom level of the map

isPng() Boolean Abstract, must be implemented in custom tile layers

Returns true if the tiles are PNG images; otherwise,GIF is assumed

getOpacity() Number Abstract, must be implemented in custom tile layers

Returns the layer opacity between 0and 1, where 0istransparent and 1is opaque

Ngày đăng: 12/08/2014, 16:20