├── style.css ├── README.textile ├── jquery.geolocation.js └── example.html /style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #eee; 3 | font-family: monaco, 'courier new', helvetica, sans-serif; 4 | } 5 | 6 | #container { 7 | width: 900px; 8 | margin: 50px auto; 9 | background: #fff; 10 | padding: 25px; 11 | border: 1px solid #ccc; 12 | } 13 | 14 | h1 { 15 | color: #eee; 16 | font-size: 12px; 17 | margin-bottom: 10px; 18 | font-weight: normal; 19 | background: #111; 20 | padding: 7px; 21 | } 22 | 23 | h1 span { 24 | color: #999; 25 | } 26 | 27 | div { 28 | margin-bottom: 35px; 29 | } 30 | 31 | #mapCanvas { 32 | height: 400px; 33 | background: #F7F7F7; 34 | text-align:center; 35 | line-height: 400px; 36 | } -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | h2. Simple jQuery plugin for Geolocation based on addresses 2 | 3 | Usage: 4 | 5 |
6 |
7 |
8 |
9 |
10 | // Geolocate and plot one address
11 | $("#mapCanvas").geolocate("1 Infinite Loop, Cupertino, Santa Clara, California 95014");
12 |
13 | // Geolocate more than one address
14 | $("#mapCanvas").geolocate([
15 | "Rua Domiciano Leite Ribeiro, 210, São Paulo, SP, Brasil",
16 | "Leonardo da Vinci, 200, SP, São Paulo"
17 | ]);
18 |
19 |
20 |
21 |
22 | For a real usage take a look on example.html file.
23 |
24 | h2. License
25 |
26 | Under no license, do whatever you want with this.
27 | Original author: 2011 Daniel Lopes,
--------------------------------------------------------------------------------
/jquery.geolocation.js:
--------------------------------------------------------------------------------
1 | (function ($) {
2 |
3 | $.fn.geolocate = function (address, options) {
4 |
5 | var defaults = {
6 | googleMaps: {
7 | zoom: 15,
8 | mapTypeId: google.maps.MapTypeId.ROADMAP
9 | }
10 | };
11 |
12 | var options = $.extend(defaults, options);
13 | var mapContainer = $(this);
14 | var geocoder = new google.maps.Geocoder();
15 |
16 | var googleMapsElement = document.getElementById(mapContainer.attr('id'));
17 | var map = new google.maps.Map(googleMapsElement, options.googleMaps);
18 |
19 | if ($.isArray(address)){
20 | for (i=0;i