Skip to content

This jQuery plugin extends the functionality of a Google Maps API polygon, allowing users to interact with its vertices. It provides features such as dragging vertices and triggering events on vertex movement.

Notifications You must be signed in to change notification settings

bewithdhanu/google-maps-vertex-interact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Google Maps Polygon Addon Plugin

This jQuery plugin extends the functionality of a Google Maps API polygon, allowing users to interact with its vertices. It provides features such as dragging vertices and triggering events on vertex movement.

Usage

Installation

Include jQuery and the Google Maps API in your HTML file, and then add the googlePolygonAddon plugin script:

<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=geometry"></script>
<script src="path/to/jquery.googlePolygonAddon.js"></script>

Initialization

javascriptCopy code

const map = new google.maps.Map(document.getElementById('map'), {
  // map configuration options
});

const polygon = new google.maps.Polygon({
  // polygon options
});

const addonInstance = $.googlePolygonAddon(map, polygon);

// Add event listeners or perform other operations as needed
$.googlePolygonAddon.refreshPosition((left, top) => {
  // Handle position refresh
});

$.googlePolygonAddon.moveVertex((vertex) => {
  // Handle vertex movement
});

// Remove event listeners if necessary
$.googlePolygonAddon.removeRefreshPositionListener();
$.googlePolygonAddon.removeVertexMoveListener();` 

Features

  • Vertex Dragging: Enable users to drag vertices of the Google Maps polygon.
  • Event Handling: Expose methods to add, remove, and handle events related to vertex movement.
  • Inactivity Timer: Set a timer to detect inactivity and stop dragging after a specified time.

Methods

refreshPosition(callback)

Add a listener for position refresh events.

  • callback: A function to be called when the position needs to be refreshed.

moveVertex(callback)

Add a listener for vertex movement events.

  • callback: A function to be called when a vertex is moved.

removeRefreshPositionListener()

Remove the listener for position refresh events.

removeVertexMoveListener()

Remove the listener for vertex movement events.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Replace YOUR_API_KEY in the HTML script tag with your actual Google Maps API key. Additionally, make sure to include the correct path to the jquery.googlePolygonAddon.js file. Once you've filled in the necessary details, you can use this README as the documentation for your Gist.``

About

This jQuery plugin extends the functionality of a Google Maps API polygon, allowing users to interact with its vertices. It provides features such as dragging vertices and triggering events on vertex movement.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published