GroundOverlay class
September 29, 2018 ยท View on GitHub
This class extends BaseClass.
Contents
Overview
Create one GroundOverlay
map: GoogleMap;
loadMap() {
let bounds: ILatLng[] = [
{"lat": 40.712216, "lng": -74.22655},
{"lat": 40.773941, "lng": -74.12544}
];
this.map = GoogleMaps.create('map_canvas', {
camera: {
target: bounds
}
});
// Add ground overlay
let groundOverlay: GroundOverlay = this.map.addGroundOverlay({
'url': "../images/newark_nj_1922.jpg",
'bounds': bounds,
'opacity': 0.5
});
}
Listen CLICK event
In order to listen the GROUND_OVERLAY_CLICK event, you need to specify the clickable option.
You can get the latitude/longitude pair of clicked position.
let bounds: ILatLng[] = [
{"lat": 40.712216, "lng": -74.22655},
{"lat": 40.773941, "lng": -74.12544}
];
// Add ground overlay
let groundOverlay: GroundOverlay = this.map.addGroundOverlay({
'url': "../images/newark_nj_1922.jpg",
'bounds': bounds,
'opacity': 0.5,
'clickable': true // default = false
});
// Catch the GROUND_OVERLAY_CLICK event
groundOverlay.on(GoogleMapsEvent.GROUND_OVERLAY_CLICK).subscribe((params: any[]) => {
let latLng: ILatLng = params[0];
...
});
API Reference
Create methods
-
map.addGroundOverlay() :orange_book:
Adds a ground overlay onto the map asynchronously.
:arrow_right: Returns
Promise<GroundOverlay> -
map.addGroundOverlaySync() :orange_book:
Adds a ground overlay onto the map synchronously.
:arrow_right: Returns
GroundOverlay
Instance methods
-
getId()
Returns the ID of instance.
:arrow_right: Returns
string -
getMap()
Return the map instance.
:arrow_right: Returns GoogleMap instance.
-
setBounds(bounds) :orange_book:
Changes the bounds of the GroundOverlay
Params Type Details bounds ILatLng[] new bounds -
setBearing(bearing) :orange_book:
Changes the bearing of the ground overlay
Params Type Details bearing number angle (clockwise) -
getBearing()
Returns the current bearing value
:arrow_right: Returns
number. -
setImage(imageUrl) :orange_book:
Change the ground overlay image.
Params Type Details imageUrl string URL of image -
setOpacity(opacity) :orange_book:
Changes the opacity of the ground overlay from 0.0 to 1.0
Params Type Details opacity number from 0.0 to 1.0 -
getOpacity()
Returns the current opacity
:arrow_right: Returns
number. -
setClickable(clickable) :orange_book:
Changes click-ability of the ground overlay
Params Type Details clickable boolean true or false -
getClickable()
Returns true if the ground overlay is clickable.
:arrow_right: Returns
boolean. -
setVisible(clickable) :orange_book:
Set ground overlay visibility
Params Type Details visible boolean true or false -
getVisible()
Returns true if the ground overlay is visible.
:arrow_right: Returns
boolean. -
setZIndex(index) :orange_book:
Changes the ground overlay zIndex order.
Params Type Details index number z-index -
getZIndex()
Returns the current ground overlay zIndex.
:arrow_right: Returns
number. -
remove()
Remove the ground overlay.
Event
-
GROUND_OVERLAY_CLICK :orange_book:
This event is fired when you click on a ground overlay.
Params Type Details params[0] LatLng clicked position params[1] GroundOverlay ground overlay instance