|
| 1 | +# Map control |
| 2 | + |
| 3 | +This control renders can be used to render a map in your solution. The control has also the ability to search for new locations. |
| 4 | + |
| 5 | +Here is an example of the control in action: |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## How to use this control in your solutions |
| 10 | + |
| 11 | +- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../#getting-started) page for more information about installing the dependency. |
| 12 | +- In your component file, import the `Map` control as follows: |
| 13 | + |
| 14 | +```TypeScript |
| 15 | +import { Map, ICoordinates, MapType } from "@pnp/spfx-controls-react/lib/Map"; |
| 16 | +``` |
| 17 | + |
| 18 | +- Use the `Map` control in your code as follows: |
| 19 | + |
| 20 | +```TypeScript |
| 21 | +<Map titleText="New of London" |
| 22 | + coordinates={{ latitude: 51.507351, longitude: -0.127758 }} |
| 23 | + enableSearch={true} /> |
| 24 | +``` |
| 25 | + |
| 26 | +## Implementation |
| 27 | + |
| 28 | +The `Map` control can be configured with the following properties: |
| 29 | + |
| 30 | +| Property | Type | Required | Description | Default | |
| 31 | +| ---- | ---- | ---- | ---- | ---- | |
| 32 | +| titleText | string | no | Title label to show above the control. | | |
| 33 | +| coordinates | ICoordinates | yes | Coordinates required for rendering the control. | | |
| 34 | +| enableSearch | boolean | no | Allow the user to search for new locations. | | |
| 35 | +| zoom | number | no | Zoom level for the maps on display (range 1-15). | 10 | |
| 36 | +| width | number | no | Width of the maps area in percentage. | 100% | |
| 37 | +| height | number | no | Height of the maps area. | 300px | |
| 38 | +| mapType | MapType | no | Type of the map to render. | standard | |
| 39 | +| loadingMessage | string | no | Custom loading message. | | |
| 40 | +| errorMessage | string | no | Custom error message. | | |
| 41 | +| mapsClassName | string | no | Custom CSS class name. | | |
| 42 | +| errorMessageClassName | string | no | Custom CSS error class name. | | |
| 43 | + |
| 44 | +`ICoordinates` interface: |
| 45 | + |
| 46 | +| Property | Type | Required | Description | Default | |
| 47 | +| ---- | ---- | ---- | ---- | ---- | |
| 48 | +| latitude | number | yes | Latitude of the map to display. | | |
| 49 | +| longitude | number | yes | Longitude of the map to display. | | |
| 50 | + |
| 51 | +`MapType` enum: |
| 52 | + |
| 53 | +| Name | |
| 54 | +| ---- | |
| 55 | +| standard | |
| 56 | +| cycle | |
| 57 | +| normal | |
| 58 | +| transport | |
| 59 | + |
| 60 | + |
| 61 | + |
0 commit comments