Skip to main content

Config Options

All these config options can be set on individual mapInput elements using data attributes with the config name in kebab case. For example to customise the pinBackground, you can use the data-pin-background attribute.

To override global config options, you can do so before mapInput is initialized. For example, to change the default iconPrefix:

import {mapInput} from '@javaabu/js-map-selector';

mapInput.config.iconPrefix = 'zmdi';

mapInput.init();
Config OptionTypeDefaultDescription
iconPrefixString'fa'Prefix to be used for icons when setting a pin icon
iconClassString'map-selector-icon'Additional class added to pin icons
mapSelectorString'.map-selector-map'Selector for the element to display the map
latInputString'input.map-selector-lat'Selector for latitude input
lngInputString'input.map-selector-lng'Selector for longitude input
searchInputString'.map-selector-search'Selector for the search input to be used within the map to set the location by search
latNumbernullThe default latitude. Must be a valid latitude value. If latInput is available, will load the latitude from its value.
lngNumbernullThe default longitude. Must be a valid longitude value. If lngInput is available, will load the longitude from its value.
radiusNumbernullThe radius of the circle when using the radius feature. If radiusInput is available, will load the radius from its value. To use this enableRadius must be true. The radius can be set in either meters or kilometers by using the radiusUnit config.
polygonStringnullThe path of the polygon as a WKT string when using the polygon feature. The wrapping POLYGON() string can be omitted if desired. Only supports polygons with a single path. All points in the path must be valid latitude and longitude values. Must have more than 2 points and the first and last points should be same. If polygonInput is available, will load the polygon from its value. To use this enablePolygon must be set to true.
clearBtnString'.map-selector-clear-btn'Selector for the clear button that's used to clear the inputs
zoomInteger14Map zoom level
disabledBooleanfalseWhether to disable the map selector inputs. This will make all map elements (marker, circle, polygon) uneditable and will also hide the search input. This option can be useful when only displaying map elements without any inputs.
animateBooleantrueWhether to animate in the map pin. This will add the pinAnimationClass to the marker when the map is initially displayed and remove it after animation is ended.
pinAnimationClassString'map-selector-marker-drop'The CSS class used to animate the marker.
enableMarkerBooleantrueWhether the marker should be displayed.
pinImageStringnullUrl of the image to use for the marker. If using this option, pinIcon, pinScale, pinBackground, pinBorderColor and pinGlyphColor will not apply.
pinIconStringnullIcon to be displayed as the marker pin glyph
pinScaleNumber1.5The size of the marker. Will not work with pinImage option.
pinClassString'map-selector-marker'Additional CSS class added to the marker. Can be used to further style the marker.
pinBackgroundStringnullBackground color for the marker pin as a CSS color string.
pinBorderColorStringnullBorder color for the marker pin as a CSS color string.
pinGlyphColorStringnullBackground color for the marker pin as a CSS color string. The glyph is the circle that's displayed on the pin.
enableRadiusBooleanfalseWhether the radius input circle should be displayed.
radiusInputString'input.map-selector-radius'Selector for the radius input.
radiusUnitString'm'Which unit to use for radius. Can be either 'm' for meters or 'km' for kilometers.
radiusPrecisionInteger0How many decimal places should be used for the radius when setting the radiusInput value when the radius is updated upon editing the circle.
circleStrokeColorString'#FF9800'Border color for the radius input circle as a CSS color string.
circleStrokeOpacityNumber0.8Opacity of the radius input circle border.
circleStrokeWeightInteger3Thickness of the radius input circle border.
circleFillColorString'#FF9800'Background color for the radius input circle as a CSS color string.
circleFillOpacityNumber0.2Opacity of the radius input circle background.
enablePolygonBooleanfalseWhether the polygon should be displayed.
polygonRadiusNumber10"Radius" (in meters) of the default square polygon when no polygon path is provided. This will create a square of length twice the size with the mid point at the provided lat and lng.
polygonInputString'.map-selector-polygon'Selector for the polygon input.
polygonStrokeColorString'#FF5722'Border color for the polygon as a CSS color string.
polygonStrokeOpacityNumber0.8Opacity of the polygon border.
polygonStrokeWeightInteger3Thickness of the polygon border.
polygonFillColorString'#FF5722'Background color of the polygon as a CSS color string.
polygonFillOpacityNumber0.2Opacity of the polygon background.
mapIdString'DEMO_MAP_ID'Id of the map if using a customized Google Map