Skip to content

Map (gm-map)


The Map is the core component of the library (and Google Maps). All the other components are created by placing them inside the Map component.

Simple Use (demo)

html
<template>
  <div style="height: 500px; width: 100%">
    <gm-map />
  </div>
</template>

<script setup>
import { gmMap } from 'v3-gmaps';
</script>

Props

PropsTypeDefaultDescription
centerGmPosition{ lat: 20, lng: 0 }The initial Map center.
zoomnumber2The initial Map zoom level.
mapIdstringDEMO_MAP_IDMap ID for Advanced Markers support.
clickableIconsbooleanundefinedWhether map points of interest are clickable.
disableDefaultUIbooleanundefinedWhether to disable all default UI controls.
mapTypeIdGmMapTypeId-The initial Map mapTypeId.
restrictionGmMapRestriction-Bounds and strictness constraints for the map view.
throttlenumber200The event throttle value in milliseconds.
optionsgoogle.maps.MapOptions{}Google Maps MapOptions interface

Events

EventTypeDescription
bounds_changedGmBoundsThis event is fired when the viewport bounds have changed.
center_changedGmPositionThis event is fired when the map center property changes.
clickGmPositionThis event is fired when the user clicks on the map.
contextmenuGmPositionThis event is fired when the DOM contextmenu event is fired on the map container.
dblclickGmPositionThis event is fired when the user double-clicks on the map.
drag-This event is repeatedly fired while the user drags the map.
dragend-This event is fired when the user stops dragging the map.
dragstart-This event is fired when the user starts dragging the map.
errorstringSpecial event if a the Map encountered an error. It returns the error message if there is one.
heading_changednumberThis event is fired when the map heading property changes.
idle-This event is fired when the map becomes idle after panning or zooming.
maptypeid_changedstringThis event is fired when the mapTypeId property changes.
mountedgoogle.maps.MapOn mounted the component will emit the Google Maps object it represents.
mousemoveGmPositionThis event is fired whenever the user's mouse moves over the map container.
mouseoutGmPositionThis event is fired when the user's mouse exits the map container.
mouseoverGmPositionThis event is fired when the user's mouse enters the map container.
projection_changed-This event is fired when the projection has changed.
rightclickGmPositionThis event is fired when the user right-clicks on the map.
tilesloaded-This event is fired when the visible tiles have finished loading.
tilt_changednumberThis event is fired when the map tilt property changes.
unmountedgoogle.maps.MapOn unmounted the component will emit the Google Maps object it represents.
visible_region_changedgoogle.maps.VisibleRegionThis event is fired when the visible region on the map changes.
zoom_changednumberThis event is fired when the map zoom property changes.

Notes

  • gm-map has most of the properties and events Google Maps' Map has.
  • The element that contains <gm-map /> should have a height and width style defined so that it can grow into it. If you can't see the map, that may be your problem.
  • Double clicking will result in both click and dblclick events firing (in that order).
  • The contextmenu even should be used instead of rightclick as it will accommodate Mac and mobile devices' methods of right clicking too.
  • To make demo's and tests simpler, zoom is defaulted to 2 and center is defaulted to { lat: 20, lng: 0 } to simplify demo's and tests.
  • The error event does not capture Google Maps errors - only those coming from Vue and/or the implementation. Things like invalid referrer errors are not able to be captured through this event.

Released under the MIT License.