Skip to main content

Search Address Events

AddressSearched

Description

The AddressSearched event is triggered when a user initiates a search for a specific address on a map using the Maptaskr for Power Pages App. This event provides information about the searched text.

Usage

To listen for the AddressSearched event, you can use the on method of the window['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].on("AddressSearched", function(text) {

console.log("text: " + text);

});

In the example above, we've registered an event listener for the AddressSearched event. When the event occurs, the provided call-back function is executed, logging the searched text to the console.

Parameters

  • text (string): The text or address that was searched for on the map.

Removing Event Listeners

To remove the event listener for the AddressSearched event, you can use the off method of the window['maptaskrPCF'] object. This is useful when you no longer want to listen for this specific event.

Example

window['maptaskrPCF'].off("AddressSearched");

In the example above, the event listener for AddressSearched is removed, ensuring that the associated call-back function no longer executes when the event is triggered.

AddressesFound

Description

The AddressesFound event is triggered when a user's address search on a map using the Maptaskr for Power Pages App returns one or more results. This event provides information about the search type, searched text, and the search results.

Usage

To listen for the AddressesFound event, you can use the on method of the window['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].on("AddressesFound", function(type, text, results) {

console.log("text: " + text);

console.log("results: " + JSON.stringify(results));

});

In the example above, we've registered an event listener for the AddressesFound event. When the event occurs, the provided call-back function is executed, logging the search type, searched text, and the search results (in JSON format) to the console.

Parameters

  • type (string): The type or category of the address search (e.g., "Geocoding" or "Reverse Geocoding").
  • Text (string): The text or address that was searched for on the map.
  • Results (object): The search results, typically in JSON format, providing details about the found addresses.

Response Example

The Results returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)

"[
{"title":"115 32, 92246, Lauka, Hiiumaa vald, Hiiu Maakond, EST"},
{"title":"115 32, 20139, Ukmergė, Ukmergės rajono savivaldybė, Vilniaus Apskritis, LTU"},
{"title":"115 32, 20140, Ukmergė, Ukmergės rajono savivaldybė, Vilniaus Apskritis, LTU"},
{"title":"Via 115 32, 73048, Nardò, Lecce, ITA"},
{"title":"Strada 115 32, 317235, Pecica, Arad, ROU"},
{"title":"Strada Provinciale 115 32, 73048, Nardò, Lecce, ITA"}
]"

"[
{"title":"-32.132166, 115.858761 (Malata Cres, Success, Perth, Western Australia, 6164)","geometry":[12897337.96901374,-3780672.0487148887]}
]"

Removing Event Listeners

To remove the event listener for the AddressesFound event, you can use the off method of the window['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].off("AddressesFound");

In the example above, the event listener for AddressesFound is removed, ensuring that the associated call-back function no longer executes when the event is triggered.

AddressSelected

Description

The AddressSelected event is triggered when a user selects an address from search results on a map using the Maptaskr for Power Pages App. This event provides information about the selected address text and its associated location.

Usage

To listen for the AddressSelected event, you can use the on method of the window['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].on("AddressSelected", function(text, location) {

console.log("text: " + text);

console.log("location: " + location);

});

In the example above, we've registered an event listener for the AddressSelected event. The provided call-back function is executed when the event occurs, logging the selected address text and its associated location to the console.

Parameters

  • text (string): The text or address that was selected from the search results.
  • location (string): The location information associated with the selected address.

Response Example

The location returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)

{
"x":2757280.325069334,
"y":7410000.549894081
}

[12897337.96901374,-3780672.0487148887]

Removing Event Listeners

To remove the event listener for the AddressSelected event, you can use the off method of the window['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].off("AddressSelected");

In the example above, the event listener for AddressSelected is removed, ensuring that the associated call-back function no longer executes when the event is triggered.