Skip to content

Programmatically rotate a google.maps.Polygon around an angle or its center using Google Maps V3

License

Notifications You must be signed in to change notification settings

ahmadnassri/google-maps-polygon-rotate

Repository files navigation

Google Maps Polygon Rotate

Release License Code Climate Test Coverage Build Status

Rotate a google.maps.Polygon on Google Maps V3 relative to a google.maps.LatLng

Table of contents

Quick start

Three quick start options are available:

git clone git@github.com:ahmadnassri/google-maps-polygon-rotate.git


- Install with [Bower](http://bower.io)
  ```bash
bower install google-maps-polygon-rotate

What's included

Within the download you'll find the following files, providing both compiled and minified variations:

google-maps-polygon-rotate/
├── dist
│   └── google.maps.Polygon.rotate.min.js
└── src
    ├── google.maps.LatLng.distanceTo.js
    ├── google.maps.Point.rotate.js
    ├── google.maps.Polygon.getCenter.js
    └── google.maps.Polygon.rotate.js

Sample Usage

start by creating a new log instance:

function initialize() {
  var mapOptions = {
    zoom: 5,
    center: new google.maps.LatLng(24.886436490787712, -70.2685546875),
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  var bermudaTriangle;

  var map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

  // Define the LatLng coordinates for the polygon's path.
  var triangleCoords = [
    new google.maps.LatLng(25.774252, -80.190262),
    new google.maps.LatLng(18.466465, -66.118292),
    new google.maps.LatLng(32.321384, -64.75737),
    new google.maps.LatLng(25.774252, -80.190262)
  ];

  // Construct the polygon.
  bermudaTriangle = new google.maps.Polygon({
    paths: triangleCoords,
    strokeColor: '#FF0000',
    strokeOpacity: 0.8,
    strokeWeight: 2,
    fillColor: '#FF0000',
    fillOpacity: 0.35
  });

  bermudaTriangle.setMap(map);

  google.maps.event.addListener(bermudaTriangle, 'click', function rotate () {
    var origin = bermudaTriangle.getCenter();

    bermudaTriangle.rotate(90, origin);
  });
}

google.maps.event.addDomListener(window, 'load', initialize);

Documentation

Refer to the Wiki for detailed API documentation.

Bugs and feature requests

Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Compiling Built with Grunt

This project uses Grunt. If you haven't used Grunt before, be sure to check out the Getting Started guide.

Troubleshooting dependencies

Should you encounter problems with installing dependencies or running Grunt commands, uninstall all previous dependency versions (global and local). Then, rerun npm install.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests.

Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.

Contribute and Earn

Donate bitcoins to this project or make commits and get tips for it. If your commit is accepted by project maintainer and there are bitcoins on its balance, you will get a tip!

tip for next commit

Donating

Donations are welcome to help support the continuous development of this project.

GitTip PayPal

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major while resetting minor and patch
  • New additions without breaking backward compatibility bumps the minor while resetting the patch
  • Bug fixes and misc changes bumps only the patch

For more information on SemVer, please visit http://semver.org/.

Authors

License

Licensed under the MIT license.

About

Programmatically rotate a google.maps.Polygon around an angle or its center using Google Maps V3

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published