Map Location
WdLocation
Notes
This component calls the Tencent Maps Service and consumes API quota. You can check key usage at the Tencent Maps Open Platform. For details, refer to the key Quota Description.
Applicable Scenarios
Enabling location pinning in forms


Basic Capabilities
Bind Geographic Location Field
After the form container is bound to the data model, geographic location fields in the model are automatically rendered as a map location component, enabling location pinning.
Configuration Guide
The map location component requires map API configuration to be used. Click Map API and select Tencent Maps API. If no API exists, create a new Tencent Maps API first. For details, refer to Tencent Maps API.
For Mini Program usage, configure according to the following steps
Mini Program applications invoke WeChat's official wx.getLocation interface to achieve location positioning. They must comply with the category requirements restricted by Mini Programs (specific categories are introduced in the wx.getLocation documentation click to view). Additionally, under the "Development" - "Development Management" - "Interface Settings" module in the WeChat Official Platform, self-enable the permission for the "Obtain current geographic location and speed" interface.

Due to Mini Program restrictions: To enable developers to normally use interfaces such as obtaining approximate geographic locations and to optimize subsequent code review processes, starting from July 14, 2022, developers must pre-configure in the app.json file when using location-related interfaces. WeChat Documentation Please open the commom/mp_config file in the low-code editor and configure the following properties in appJson.
appJson: {
// Mini Program interface permissions related settings, optional
permission: {
'scope.userLocation': {
desc: desc: 'Your location information will be used to demonstrate the effect of the Mini Program location interface',
},
},
requiredPrivateInfos: [ "getLocation" ]
}
Description of Mini Program submission for review error scenarios (Open the console to view error messages)
- Error message: Request to WeChat interface data error; 61040; The code contains unconfigured privacy interface getLocation in ext.json (temporary..._use set to true). Please refer to step 2 in the Mini Program configuration above to configure the appJson file.
- Error message: Request to WeChat interface data error; 61040; The privacy interface getLocation configured in ext.json lacks permission. Apply for permission before resubmitting for review. Refer to step 1 in the Mini Program configuration above to apply for the wx.getLocation interface permission.
Description of browser location failure scenarios
1) Browser not Support html5 geolocation: The browser does not support the native geolocation interface, such as lower versions of IE browsers, etc.
2) Geolocation permission denied: The location permission has been disabled by the user. The user needs to enable location permissions for both the device and browser, and click the "Allow location access" option in the browser pop-up window.
3) Geolocation permission denied: The browser prohibits location requests from non-secure domains. For example, Chrome and iOS 10 have progressively banned such requests. In this case, you need to upgrade the site to HTTPS. Note that Chrome does not prohibit location access under HTTP protocol for domains like localhost.
4) Geolocation permission denied: Access to geolocation was blocked over secure connection with mixed content, meaning http resources are referenced within an Https page.
5) Get geolocation time out: Browser geolocation times out, including native timeouts. You can increase the timeout setting appropriately to reduce this occurrence. Additionally, the geolocation interface of certain browsers (such as google Chrome) is a 'black hole', where location requests receive no response at all, resulting in timeout failures.
6) Get geolocation failed: Geolocation failed. Chrome, Firefox, and some shell browsers access geolocation services located abroad, which face significant restrictions and have a high failure rate.
Quota Limits Description: After the map location component is configured with the Tencent Maps API, the quota limits of Tencent Maps API will directly impact the functionality of the map location component. For details, refer to: Quota Limits Description
The main services used within the component include:
Service Name Service Path Nearby Recommendations /ws/place/v1/explore Place Search /ws/place/v1/search Keyword Input Suggestion /ws/place/v1/suggestion Geocoding /ws/geocoder/v1/?address=*
Extended Scenarios
Positioning Adjustment Range Configuration
The component provides a "Positioning Adjustment Range" attribute that constrains the user's point selection range, allowing positioning only within a certain radius of the actual current location point.


Practices for Other Scenarios
Refer to the Form Scenario Practice Guide to explore various supported scenarios and implementation solutions for forms.
Example
Interactive Preview
Component Input Status
Style API Example
#wd-page-root .wd-pc-location-root .wd-location__label {
color: cyan;
background-color: black;
display: flex;
justify-content: center;
}
#wd-page-root .wd-h5-location-root .wd-location-location {
border-color: cyan;
color: cyan;
background-color: black;
border-width: 2px;
border-radius: 6px;
}
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
|---|
| Display Headlines | labelVisible | boolean | Default value: true |
| Title alignment | labelAlign | string | In the scenario, the form by default follows the title alignment configuration of the form container. |
| Line break in heading | labelWrap | boolean | If the title content is too long when closed, show one line with overflow omitted; when enabled, show with line breaks. In form scenarios, it follows the form container's title line break configuration by default. |
| Title position | layout | string | Set title display position in form component. In the scenario, it follows the title position configuration of the form container by default. |
| Title width | labelWidth | string | In the scenario, the form follows the title width configuration of the form container by default. |
| Heading Note | labelTips | string | Configure tooltip content for the heading |
| Display clear button | clearable | boolean | Enabled, quick clear button is provided by Default value: true |
| Prompt. | extra | string | The prompt content is displayed below the input box after configuration. |
| Display longitude and latitude | showLngLat | boolean | Display longitude and latitude of the selected location |
| display map | showMap | boolean | Display the selected location on the map |
| Display underscore on mobile terminal | borderedH5 | boolean | After closing, the mobile terminal does not show the bottom underline Default value: true |
| Locating adjustment range | locationRange | string | 0 |
| custom scope | customRange | number | 0 |
| Permission to scale | zoom | boolean | Permission to scale the map Default value: true |
| Allow drag | drag | boolean | Permission to drag the map Example: true |
| Status. | status | string | Example: "edit" |
| Required | required | boolean | |
| Required identifier | requiredFlag | boolean | Enabled, the component will display a required asterisk tag if mandatory. Default value: true |
| Required validation note | requiredMsg | string | Example: "该项为必填项" |
| Bound field | name | string | The Key value of a form field is used to match the field identifier of the data model when submitting data. It must be unique within the form. |
| Title content. | label | string | Example: "地图" |
| Map APIs | dataSource | object | Associate Tencent Maps APIs, the mini program will call the Official WeChat API for localization. Please ensure the relevant APIs are approved. For details, refer to the component documentation. |
| Default position | locationType | number | Default location value Example: 1 |
| Default value | value | object | Example: null |
| Placeholder text | placeholder | string | Example: "选择地理位置" |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
|---|
| value change | change | object
| Compatible with all platforms | Trigger when a user modifies a component value |
| Map component error event | error | object
| Mobile,PC | Map loading failed, or trigger on abnormality in map component usage |
Properties API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName, such as $w.input1.value. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
|---|
| Bound field | name | string | The Key value of a form field is used to match the field identifier of the data model when submitting data. It must be unique within the form. |
| Title content. | label | string | |
| Default value | value | object | |
| Required | required | boolean | |
| Indicates whether to display | visible | boolean | Whether to display the component |
| Whether to disable | disabled | boolean | Component Disabled |
| Specify whether it is read-only or not. | readOnly | boolean | Whether the component is read-only |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
|---|
| set value | setValue | object
| 通过 $w.id1.setValue({address:"深圳站",geopoint:{coordinates:[114.117209,22.53168]}}) 设置组件值 |
| Show/Hide Settings | setVisible | boolean显示 | Set the component to hidden via $w.id1.setVisible(false) |
| Set Disabled | setDisabled | boolean禁用 | Set the component to disabled with $w.id1.setDisabled(true) |
| Clear value | clearValue | Clear the component value with $w.id1.clearValue() | |
| Set as read-only | setReadOnly | boolean只读 | Set the component to read-only via $w.id1.setReadOnly(true) |
| Trigger validation | handleValidate | Validate the component value via $w.id1.handleValidate() | |
| Clear verification | clearValidate | Clear component validation via $w.id1.clearValidate() |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn, and control individual component styles with :scope. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
|---|
| root element | .wd-location-root | Outermost component element |
| H5 root element | .wd-h5-location-root | Settable root element style for the H5 side |
| PC-side root element | .wd-pc-location-root | Settable root element style for the PC side |
| Mini program root element | .wd-mp-location-root | Settable root element style for mini program |
| Component title style | .wd-location-root .wd-form-item-wrap__label | Component title element |
| form control root node style | .wd-location-root .wd-form-item-wrap__control | Set form control root element style |
| Editing status - Location information style | .wd-location-root .wd-location__info | Editing status - Location information style |
| Editing status - Placeholder text style | .wd-location-root .form-location-con__text | Editing status - Placeholder text style |
| Editing status - Verification information | .wd-location-root .wd-g-text-error | Set component verification information style |
| prompt text | .wd-location-root .wd-form-item__help-text | Set the text style of the component prompt |
| Disabled status - Location information style | .wd-location-root .is-disabled .wd-location__info | Disabled status - Location information style |
| read-only status - form value style | .wd-location-root .wd-form-item__readonly-value | Set component read-only status |
Version Changes
- Property Changes
- Style Changes
- widget api Changes