<apex: map> Component in Visualforce Page

The <apex: map> is another important component that shows a map(JavaScript-based map) with panning, zooming, and based on our Salesforce data or other data.

The <apex: map> component has the following attributes:

1. center

The center attribute is an Object-type attribute used for specifying the location of the map center. If the <apex: map> component doesn't have any child <apex: mapMarker> component, we need to use the center attribute. By default, the map is centered on displaying all the markers.

Syntax:

2. height

The height is a string-type attribute used for specifying the map's height. We can define its values either in percentages or pixels.

Syntax:

3. width

The width is a string-type attribute used for specifying the map's width. We can define its values either in percentages or pixels.

Syntax:

4. id

The id is a string-type attribute, i.e., a unique identifier that allows this component to be referenced by other components on the page.

Syntax:

5. mapType

The mapType is a string-type attribute that is used for specifying the type of the map. A map can be one of the following types:

  1. satellite
  2. hybrid
  3. roadmap

Syntax:

6. rendered

The rendered is a Boolean-type attribute that specifies whether this component is rendered on the page. The boolean value true is set as a default value for this attribute.

Syntax:

7. scrollBasedZooming

The scrollBasedZooming is a Boolean-type attribute used to specify whether this component can be zoomed via the scroll wheel. Boolean-value true is set as a default value for this attribute.

Syntax:

8. showOnlyActiveInfoWindow

The showOnlyActiveInfoWindow is a Boolean-type attribute used to specify whether this component allows us to display multiple info windows at the same time. Boolean-value true is set as a default value for this attribute.

Syntax:

9. zoomLevel

The zoomLevel is an Integer- type attribute used to specify the initial map zoom level. The possible value for this attribute is from 0 to 18.

Syntax:

Note: Visualforce mapping components are not currently available in the Developer Edition organization.

Let's take an example to understand how we can use this component on the Visualforce page:

ApexMapExample.vfp

Output

apex: map Component in Visualforce Page