Skip to content

Geowidget integration

Get started

To start using Geowidget on your website:

  1. Contact your InPost Account Manager or the Integration Team.
  2. Share your domain URL that will be correlated with a Geowidget key.

Basic integration

Add the following lines to the <head> of your page:

<link rel="stylesheet" href="https://geowidget.inpost-group.com/inpost-geowidget.css"/>
<script src="https://geowidget.inpost-group.com/inpost-geowidget.js" defer></script>
<script>
  function afterPointSelected(point) {
    alert('Selected point: ' + point.name);
  }
</script>

Then embed the element where the map should appear:

<inpost-geowidget
  token="your-geowidget-key"
  config="parcelCollect"
  onpoint="afterPointSelected"
  language="en"
  country="PL,IT"
>
</inpost-geowidget>

The custom element has no intrinsic size. Give it an explicit height in your CSS, otherwise it renders with zero height and the map looks like it failed to load:

inpost-geowidget {
  display: block;
  width: 100%;
  height: 500px;
}

Advanced integration

Instead of a globally named function, you can listen for the onpointselect event:

<link rel="stylesheet" href="https://geowidget.inpost-group.com/inpost-geowidget.css"/>
<script src="https://geowidget.inpost-group.com/inpost-geowidget.js" defer></script>
<script>
  document.addEventListener('onpointselect', (event) =>
    alert(event.detail.name),
  );
</script>
<inpost-geowidget
  token="your-geowidget-key"
  config="parcelCollect"
  onpoint="onpointselect"
  language="en"
  country="PL"
>
</inpost-geowidget>

Element attributes

attributerequireddescription
tokenyesYour Geowidget key, correlated with your domain URL, generated in the InPost Merchant Portal or provided by InPost Integration Team.
configyesDefines which point functions / types are displayed on the map. See Config options.
onpointnoName of a global function (or an event name) invoked after a point is selected on the map.
languagenoDefault interface language. If the user has already used the widget, their previous language is used. One of: pl, en, uk, de, es, fr, it, nl, pt.
countrynoOne or more comma-separated country codes from: BE, GB, ES, FR, IT, LU, NL, PL, PT, AT, HU. The first value sets the default map location when geolocation is disabled on the device.

Config options

#Descriptionconfig valuePoints typeStatusesfunctionspayment_availablelocation_247Partner idFilters for type
1Showing pickup points for pre-paid ordersparcelCollectparcel_lockerOperating, NonOperatingparcel_collectfalsefalse—All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: parcel_locker_superpop
2Presentation of collection points for pick-up ordersparcelCollectPaymentparcel_lockerOperating, NonOperatingparcel_collecttrue——All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: parcel_locker_superpop
3Presentation of collection points for PWW ordersparcelCollect247parcel_lockerOperating, NonOperatingparcel_collect—true—All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: parcel_locker_superpop
4Presentation of senders' pointsparcelSendparcel_locker, popOperatingparcel_send———All: parcel_locker, pop
Parcel lockers: parcel_locker_only
Parcel point: pop, parcel_locker_superpop
5Presentation of InPost pickup points for pre-paid ordersparcelCollectInPostparcel_lockerOperating, NonOperatingparcel_collect——0,33,61All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: pop, parcel_locker_superpop
6Presentation of InPost collection points for cash-on-delivery ordersparcelCollectPaymentInPostparcel_lockerOperating, NonOperatingparcel_collect——0,33,61All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: pop, parcel_locker_superpop
7Presentation of APMX (fridge modules)cooledDepositparcel_lockerOperating, NonOperatingcool_parcel_collect———All: parcel_locker
Parcel lockers: parcel_locker_only
Parcel point: pop, parcel_locker_superpop

A dash (—) marks columns that do not apply to a given configuration.


Geowidget API

Accessing the API

The API object becomes available on the inpost.geowidget.init event:

<inpost-geowidget
  id="geowidget"
  onpoint="handlePointSelection"
  token="your-geowidget-key"
  language="en"
  config="parcelCollect"
></inpost-geowidget>

<script>
  const geowidget = document.getElementById('geowidget');
  // Listener for the geowidget init event
  geowidget.addEventListener('inpost.geowidget.init', (event) => {
    // Reference to the api object
    const api = event.detail.api;

    // Call an api method
    api.changePosition({ longitude: 20.318968, latitude: 49.731131 }, 16);
  });
</script>

There is no attribute for the initial map position, zoom level or search phrase. Those are reachable only through the api, which means the widget always appears at its own default location first and can be moved only after inpost.geowidget.init.

Methods

MethodDescription
search(query: string): voidRun a search and show the result list.
hideSearchResult(): voidHide the search result list.
clearSearch(): voidClear the search input.
showPoint(name: string): voidShow the point with the given name on the map.
showPointDetails(name: string): voidOpen the details panel for the point with the given name.
selectPoint(name: string): voidTrigger the onpoint callback with the data of the point with the given name.
changeLanguage(lang: LanguageCode): voidChange the interface language.
changePointsType(type: FilterPointsType): voidChange the type of points shown on the map.
changeZoomLevel(zoom: number): voidChange the map zoom level.
changePosition(position: LocationInterface, zoom?: number): voidCenter the map on the given position; optionally set the zoom level.
addPointSelectedCallback(callback: (point: PointInterface) => void): voidRegister a callback invoked after a point is selected. Multiple callbacks can be registered.

Point selection

A selected point is delivered either to the function named in the onpoint attribute, or to any callback registered with addPointSelectedCallback. The callback receives a PointInterface object (see Types).

api.addPointSelectedCallback((point) => {
  console.log('Selected point:', point.name, point.address_details);
});

Types

// Interface language
type LanguageCode =
  'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt' | 'uk' | 'de';

// Point type filter used by changePointsType()
type FilterPointsType = 'ALL' | 'PARCEL_LOCKER' | 'POP';

// Geographic position used by changePosition()
interface LocationInterface {
  longitude: number;
  latitude: number;
  distance?: number;
}

// Physical point type(s)
enum PointTypeEnum {
  PARCEL_LOCKER = 'parcel_locker',
  POP = 'pop',
  PARCEL_LOCKER_SUPERPOP = 'parcel_locker_superpop',
}

interface AddressInterface {
  building_number: string;
  city: string;
  flat_number: string;
  post_code: string;
  province: string;
  street: string;
}

// Delivered to onpoint / addPointSelectedCallback
interface PointInterface {
  name: string;
  image_url: string;
  location: LocationInterface;
  type: PointTypeEnum[];
  address_details: AddressInterface;
  address: { line1: string; line2: string };
  location_247: boolean;
  location_description: string;
  payment_point_descr: string;
  apm_doubled: string;
  virtual: string;
  opening_hours: string;
  recommended_low_interest_box_machines_list: string[];
  payment_type: { 2?: string };
  partner_id: number;
  physical_type_mapped?: string;
  physical_type_description?: string;
  easy_access_zone?: boolean;
  operating_hours_extended: OpenedHoursWeek;
  country: string;
}

interface OpenedHoursWeek {
  customer?: {
    [
      weekday in
        | 'monday'
        | 'tuesday'
        | 'wednesday'
        | 'thursday'
        | 'friday'
        | 'saturday'
        | 'sunday'
    ]: OpenedHoursRange[];
  };
}

interface OpenedHoursRange {
  start: number;
  end: number;
}

Try it live

Adjust the config, points type, language, position and address below to see how the map reacts. These map directly to the element attributes and the API methods described above.

Widget configuration

Changing these reloads the map.

Country

Optional. Countries you hold a contract for.

Map position

Search and filtering

Every control applies to the map as you change it. Config and Country reload the map itself.

Loading the map…

Pick a point on the map to see what your onpoint handler receives.