├── README.textile ├── example.html ├── jquery.geolocation.js └── style.css /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, -------------------------------------------------------------------------------- /example.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | GoogleMaps Geolocation with jQuery 6 | 7 | 8 | 9 | 10 |
11 |
12 | Loading Map 13 |
14 | 15 |
16 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 41 | 42 | -------------------------------------------------------------------------------- /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