From a212a6c96018a73dd7b0f6672cad4ae1283301ce Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Thu, 16 Jul 2015 14:17:00 +0200 Subject: [PATCH 01/12] Update jquery.googlemap.js --- jquery.googlemap.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index c42fa0f..d231942 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -30,8 +30,7 @@ $(function() { scrollwheel: false, streetViewControl: false, overviewMapControl: false, - mapTypeControl: false, - draggable: false + mapTypeControl: false }); $(this).data('googleMap', map); From decf53532b5bec0084310249a49a3879d3fd7f44 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Tue, 4 Aug 2015 18:00:12 +0200 Subject: [PATCH 02/12] Various bugfixes --- googlemap.jquery.json | 13 +-- jquery.googlemap.js | 221 ++++++++++++++++++++++-------------------- 2 files changed, 116 insertions(+), 118 deletions(-) diff --git a/googlemap.jquery.json b/googlemap.jquery.json index 27ae407..ff92592 100644 --- a/googlemap.jquery.json +++ b/googlemap.jquery.json @@ -1,7 +1,7 @@ { "name": "googlemap", "title": "Google Map", - "version": "1.4.2", + "version": "1.4.3", "author": { "name": "Thibault HENRY", "email": "thibaulthenry@tilotiti.com", @@ -18,16 +18,7 @@ "docs": "http://tilotiti.github.com/jQuery-Google-Map/", "demo": "http://tilotiti.github.com/jQuery-Google-Map/", "download": "https://github.com/tilotiti/jQuery-Google-Map/archive/master.zip", - "keywords": [ - "grid", - "datagrid", - "table", - "ui", - "input", - "ajax", - "handsontable", - "spreadsheet" - ], + "keywords": ["map", "googlemap", "google", "geocode", "route"], "bugs": "http://tilotiti.github.com/jQuery-Google-Map/", "dependencies": { "jquery": ">=1.7" diff --git a/jquery.googlemap.js b/jquery.googlemap.js index d231942..b8995a2 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -72,86 +72,91 @@ $(function() { } if(params.address && typeof params.address == "string") { - geocoder = new google.maps.Geocoder(); - - geocoder.geocode({ - address : params.address, - bounds : $this.data('googleBound'), - language : $this.data('googleLang') - }, function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - $this.data('googleBound').extend(results[0].geometry.location); - - if(params.icon) { - var marker = new google.maps.Marker({ - map: $this.data('googleMap'), - position: results[0].geometry.location, - title: params.title, - icon: params.icon, - draggable: params.draggable - }); - } else { - var marker = new google.maps.Marker({ - map: $this.data('googleMap'), - position: results[0].geometry.location, - title: params.title, - draggable: params.draggable - }); - } - - if(params.draggable) { - google.maps.event.addListener(marker, 'dragend', function() { - var location = marker.getPosition(); - - var coords = {}; - - coords.lat = location.lat(); - coords.lon = location.lng(); - - params.success(coords); - }); - } - - if(params.title != "" && params.text != "" && !params.url) { - var infowindow = new google.maps.InfoWindow({ - content: "

"+params.title+"

"+params.text - }); - - var map = $this.data('googleMap'); - google.maps.event.addListener(marker, 'click', function() { - infowindow.open(map, marker); - }); - } else if(params.url) { - google.maps.event.addListener(marker, 'click', function() { - document.location = params.url; - }); - } + var geocodeAsync = function($that) { + + var geocoder = new google.maps.Geocoder(); + + geocoder.geocode({ + address : params.address, + bounds : $that.data('googleBound'), + language : $that.data('googleLang') + }, function(results, status) { + + if (status == google.maps.GeocoderStatus.OK) { + $that.data('googleBound').extend(results[0].geometry.location); + + if(params.icon) { + var marker = new google.maps.Marker({ + map: $this.data('googleMap'), + position: results[0].geometry.location, + title: params.title, + icon: params.icon, + draggable: params.draggable + }); + } else { + var marker = new google.maps.Marker({ + map: $that.data('googleMap'), + position: results[0].geometry.location, + title: params.title, + draggable: params.draggable + }); + } + + if(params.draggable) { + google.maps.event.addListener(marker, 'dragend', function() { + var location = marker.getPosition(); + + var coords = {}; + + coords.lat = location.lat(); + coords.lon = location.lng(); + + params.success(coords); + }); + } + + if(params.title != "" && params.text != "" && !params.url) { + var infowindow = new google.maps.InfoWindow({ + content: "

"+params.title+"

"+params.text + }); + + var map = $that.data('googleMap'); + + google.maps.event.addListener(marker, 'click', function() { + infowindow.open(map, marker); + }); + } else if(params.url) { + google.maps.event.addListener(marker, 'click', function() { + document.location = params.url; + }); + } + + if(!params.id) { + $that.data('googleMarker').push(marker); + } else { + $that.data('googleMarker')[params.id] = marker; + } + + if($that.data('googleMarker').length == 1) { + $that.data('googleMap').setCenter(results[0].geometry.location); + $that.data('googleMap').setZoom($that.data('googleMap').getZoom()); + } else { + $that.data('googleMap').fitBounds($that.data('googleBound')); + } + + var coords = {}; + coords.lat = results[0].geometry.location.lat(); + coords.lon = results[0].geometry.location.lng(); + + params.success(coords); - if(!params.id) { - $this.data('googleMarker').push(marker); } else { - $this.data('googleMarker')[params.id] = marker; + if($this.data('googleDebug')) + console.error("jQuery googleMap : Unable to find the place asked for the marker ("+status+")"); } - - if($this.data('googleMarker').length == 1) { - $this.data('googleMap').setCenter(results[0].geometry.location); - $this.data('googleMap').setZoom($this.data('googleMap').getZoom()); - } else { - $this.data('googleMap').fitBounds($this.data('googleBound')); - } - - var coords = {}; - coords.lat = results[0].geometry.location.lat(); - coords.lon = results[0].geometry.location.lng(); - - params.success(coords); - - } else { - if($this.data('googleDebug')) - console.error("jQuery googleMap : Unable to find the place asked for the marker ("+status+")"); - } - }); + }); + }($this); } else { $this.data('googleBound').extend(new google.maps.LatLng(params.coords[0], params.coords[1])); @@ -270,37 +275,39 @@ $(function() { } if(typeof params.end != "object") { - var geocoder = new google.maps.Geocoder(); - - geocoder.geocode({ - address : params.end, - bounds : $(this).data('googleBound'), - language : params.langage - }, function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - - var request = { - origin: params.start, - destination: results[0].geometry.location, - travelMode: google.maps.DirectionsTravelMode.DRIVING, - region: "fr", - waypoints: waypoints - }; - - direction.route(request, function(response, status) { - if (status == google.maps.DirectionsStatus.OK) { - way.setDirections(response); - } else { - if($(this).data('googleDebug')) - console.error("jQuery googleMap : Unable to find the place asked for the route ("+response+")"); - } - }); - - } else { - if($(this).data('googleDebug')) - console.error("jQuery googleMap : Address not found"); - } - }); + var geocodeAsync = function($that) { + var geocoder = new google.maps.Geocoder(); + + geocoder.geocode({ + address : params.end, + bounds : $that.data('googleBound'), + language : params.langage + }, function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + + var request = { + origin: params.start, + destination: results[0].geometry.location, + travelMode: google.maps.DirectionsTravelMode.DRIVING, + region: "fr", + waypoints: waypoints + }; + + direction.route(request, function(response, status) { + if (status == google.maps.DirectionsStatus.OK) { + way.setDirections(response); + } else { + if($that.data('googleDebug')) + console.error("jQuery googleMap : Unable to find the place asked for the route ("+response+")"); + } + }); + + } else { + if($that.data('googleDebug')) + console.error("jQuery googleMap : Address not found"); + } + }); + }($(this)); } else { var request = { origin: params.start, From 08a276cdd6a6e0a7978bce1216f159571c327cea Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Fri, 14 Aug 2015 16:41:54 +0200 Subject: [PATCH 03/12] bugfix marker with coordinate non draggable. --- jquery.googlemap.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index b8995a2..5ddd1f7 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -27,9 +27,7 @@ $(function() { zoom: params.zoom, center: new google.maps.LatLng(params.coords[0], params.coords[1]), mapTypeId: params.type, - scrollwheel: false, streetViewControl: false, - overviewMapControl: false, mapTypeControl: false }); @@ -165,13 +163,15 @@ $(function() { map: $this.data('googleMap'), position: new google.maps.LatLng(params.coords[0], params.coords[1]), title: params.title, - icon: params.icon + icon: params.icon, + draggable: params.draggable }); } else { var marker = new google.maps.Marker({ map: $this.data('googleMap'), position: new google.maps.LatLng(params.coords[0], params.coords[1]), - title: params.title + title: params.title, + draggable: params.draggable }); } @@ -191,6 +191,19 @@ $(function() { }); } + if(params.draggable) { + google.maps.event.addListener(marker, 'dragend', function() { + var location = marker.getPosition(); + + var coords = {}; + + coords.lat = location.lat(); + coords.lon = location.lng(); + + params.success(coords); + }); + } + if(!params.id) { $this.data('googleMarker').push(marker); } else { From 9b805dc0afd4ed34248a9a3e73b33655651fc648 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Fri, 14 Aug 2015 16:42:20 +0200 Subject: [PATCH 04/12] Change support URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c0ecaa..c6dbaed 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ Plugin jQuery : Create your own complet Google Map For documentation and live demo : http://tilotiti.github.com/jQuery-Google-Map/ -For support : http://www.tiloblog.com/js/jquery/jquery-plugin-google-map-creez-votre-google-map-complete +For support : http://www.tiloweb.com/js/jquery/jquery-plugin-google-map-creez-votre-google-map-complete From 2c1a232cb8c0b7642284a771d03fa6c8971f2c16 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Wed, 18 Nov 2015 10:26:16 +0100 Subject: [PATCH 05/12] Update jquery.googlemap.js --- jquery.googlemap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 5ddd1f7..8d89c21 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -6,7 +6,8 @@ $(function() { coords : [48.895651, 2.290569], type : "ROADMAP", debug : false, - langage : "english" + langage : "english", + scrollwheel: true }, params); switch(params.type) { @@ -28,7 +29,7 @@ $(function() { center: new google.maps.LatLng(params.coords[0], params.coords[1]), mapTypeId: params.type, streetViewControl: false, - mapTypeControl: false + mapTypeControl: false, }); $(this).data('googleMap', map); From 342a356bad8f154fb19b05ceedcc7409f1e0ce94 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Wed, 18 Nov 2015 10:28:06 +0100 Subject: [PATCH 06/12] Add scrollwheel option --- jquery.googlemap.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 8d89c21..9e7c781 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -30,6 +30,7 @@ $(function() { mapTypeId: params.type, streetViewControl: false, mapTypeControl: false, + scrollwheel: params.scrollwheel }); $(this).data('googleMap', map); From 4f8a713d4302113d07d5f4bb4654479c41cf4781 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Wed, 18 Nov 2015 10:37:07 +0100 Subject: [PATCH 07/12] bugfix #6 + Clean File --- jquery.googlemap.js | 164 +++++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 78 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 9e7c781..55a7864 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -62,12 +62,14 @@ $(function() { if(!$this.data('googleMap')) { if($this.data('googleDebug')) console.error("jQuery googleMap : Unable to add a marker where there is no map !"); + return false; } if(!params.coords && !params.address) { if($this.data('googleDebug')) console.error("jQuery googleMap : Unable to add a marker if you don't tell us where !"); + return false; } @@ -81,7 +83,7 @@ $(function() { address : params.address, bounds : $that.data('googleBound'), language : $that.data('googleLang') - }, function(results, status) { + }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { $that.data('googleBound').extend(results[0].geometry.location); @@ -160,7 +162,7 @@ $(function() { } else { $this.data('googleBound').extend(new google.maps.LatLng(params.coords[0], params.coords[1])); - if(params.icon) { + if(params.icon) { var marker = new google.maps.Marker({ map: $this.data('googleMap'), position: new google.maps.LatLng(params.coords[0], params.coords[1]), @@ -177,20 +179,20 @@ $(function() { }); } - if(params.title != "" && params.text != "" && !params.url) { - var infowindow = new google.maps.InfoWindow({ + if(params.title != "" && params.text != "" && !params.url) { + var infowindow = new google.maps.InfoWindow({ content: "

"+params.title+"

"+params.text }); var map = $this.data('googleMap'); - google.maps.event.addListener(marker, 'click', function() { - infowindow.open(map, marker); - }); + google.maps.event.addListener(marker, 'click', function() { + infowindow.open(map, marker); + }); } else if(params.url) { - google.maps.event.addListener(marker, 'click', function() { - document.location = params.url; - }); + google.maps.event.addListener(marker, 'click', function() { + document.location = params.url; + }); } if(params.draggable) { @@ -206,15 +208,15 @@ $(function() { }); } - if(!params.id) { - $this.data('googleMarker').push(marker); - } else { - $this.data('googleMarker')[params.id] = marker; - } + if(!params.id) { + $this.data('googleMarker').push(marker); + } else { + $this.data('googleMarker')[params.id] = marker; + } if($this.data('googleMarker').length == 1) { - $this.data('googleMap').setCenter(new google.maps.LatLng(params.coords[0], params.coords[1])); - $this.data('googleMap').setZoom($this.data('googleMap').getZoom()); + $this.data('googleMap').setCenter(new google.maps.LatLng(params.coords[0], params.coords[1])); + $this.data('googleMap').setZoom($this.data('googleMap').getZoom()); } else { $this.data('googleMap').fitBounds($this.data('googleBound')); } @@ -233,23 +235,28 @@ $(function() { this.each(function() { var $this = $(this); - if(!$this.data('googleMap')) { - if($this.data('googleDebug')) - console.log("jQuery googleMap : Unable to delete a marker where there is no map !"); - return false; - } - - var $markers = $this.data('googleMarker'); - - if(typeof $markers[id] != 'undefined') { - $markers[id].setMap(null); - if($this.data('googleDebug')) - console.log('jQuery googleMap : marker deleted'); - } else { - if($this.data('googleDebug')) - console.error("jQuery googleMap : Unable to delete a marker if it not exists !"); - return false; - } + if(!$this.data('googleMap')) { + if($this.data('googleDebug')) + console.log("jQuery googleMap : Unable to delete a marker where there is no map !"); + + return false; + } + + var $markers = $this.data('googleMarker'); + + if(typeof $markers[id] != 'undefined') { + $markers[id].setMap(null); + + if($this.data('googleDebug')) + console.log('jQuery googleMap : marker deleted'); + + return true; + } else { + if($this.data('googleDebug')) + console.error("jQuery googleMap : Unable to delete a marker if it not exists !"); + + return false; + } }); } @@ -272,57 +279,58 @@ $(function() { panel: document.getElementById(params.route), provideTripAlternatives: true }); + + document.getElementById.innerHTML = ""; var waypoints = []; - for(var i in params.step) { - var step; - if(typeof params.step[i] == "object") { - step = new google.maps.LatLng(params.step[i][0], params.step[i][1]); - } else { - step = params.step[i]; - } - - waypoints.push({ - location: step, - stopover: true - }); - } + for(var i in params.step) { + var step; + if(typeof params.step[i] == "object") { + step = new google.maps.LatLng(params.step[i][0], params.step[i][1]); + } else { + step = params.step[i]; + } + + waypoints.push({ + location: step, + stopover: true + }); + } if(typeof params.end != "object") { var geocodeAsync = function($that) { var geocoder = new google.maps.Geocoder(); - geocoder.geocode({ - address : params.end, - bounds : $that.data('googleBound'), - language : params.langage - }, function(results, status) { - if (status == google.maps.GeocoderStatus.OK) { - - var request = { - origin: params.start, - destination: results[0].geometry.location, - travelMode: google.maps.DirectionsTravelMode.DRIVING, - region: "fr", - waypoints: waypoints - }; - - direction.route(request, function(response, status) { - if (status == google.maps.DirectionsStatus.OK) { - way.setDirections(response); - } else { - if($that.data('googleDebug')) - console.error("jQuery googleMap : Unable to find the place asked for the route ("+response+")"); - } - }); - - } else { - if($that.data('googleDebug')) - console.error("jQuery googleMap : Address not found"); - } - }); - }($(this)); + geocoder.geocode({ + address : params.end, + bounds : $that.data('googleBound'), + language : params.langage + }, function(results, status) { + if (status == google.maps.GeocoderStatus.OK) { + var request = { + origin: params.start, + destination: results[0].geometry.location, + travelMode: google.maps.DirectionsTravelMode.DRIVING, + region: "fr", + waypoints: waypoints + }; + + direction.route(request, function(response, status) { + if (status == google.maps.DirectionsStatus.OK) { + way.setDirections(response); + } else { + if($that.data('googleDebug')) + console.error("jQuery googleMap : Unable to find the place asked for the route ("+response+")"); + } + }); + + } else { + if($that.data('googleDebug')) + console.error("jQuery googleMap : Address not found"); + } + }); + }($(this)); } else { var request = { origin: params.start, @@ -337,7 +345,7 @@ $(function() { way.setDirections(response); } else { if($(this).data('googleDebug')) - console.error("jQuery googleMap : Address not found"); + console.error("jQuery googleMap : Address not found"); } }); } From f7b732d1a9b123808c7ef42cd149ce0c9a756beb Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Wed, 18 Nov 2015 10:39:32 +0100 Subject: [PATCH 08/12] Plugin release --- googlemap.jquery.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemap.jquery.json b/googlemap.jquery.json index ff92592..349649a 100644 --- a/googlemap.jquery.json +++ b/googlemap.jquery.json @@ -1,7 +1,7 @@ { "name": "googlemap", - "title": "Google Map", - "version": "1.4.3", + "title": "Jquery Google Map", + "version": "1.5", "author": { "name": "Thibault HENRY", "email": "thibaulthenry@tilotiti.com", From 78bd8473499c2d99a380bd65e57c1d9e002b7201 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Thu, 19 Nov 2015 18:06:28 +0100 Subject: [PATCH 09/12] Add $this reference to success option --- jquery.googlemap.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 55a7864..651c46c 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -114,7 +114,7 @@ $(function() { coords.lat = location.lat(); coords.lon = location.lng(); - params.success(coords); + params.success(coords, $this); }); } @@ -151,7 +151,7 @@ $(function() { coords.lat = results[0].geometry.location.lat(); coords.lon = results[0].geometry.location.lng(); - params.success(coords); + params.success(coords, $this); } else { if($this.data('googleDebug')) @@ -204,7 +204,7 @@ $(function() { coords.lat = location.lat(); coords.lon = location.lng(); - params.success(coords); + params.success(coords, $this); }); } @@ -224,7 +224,7 @@ $(function() { params.success({ lat: params.coords[0], lon: params.coords[1] - }); + }, $this); } }); From 1d16f4e99a25df1e7bb527d0aa6792e9221f30fd Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Mon, 21 Mar 2016 14:04:02 +0100 Subject: [PATCH 10/12] Update v1.5 Add to the NPM registry Add some options : overviewMapControl, overviewMapControl, scrollwheel, mapTypeControl --- jquery.googlemap.js | 14 +++++++++----- googlemap.jquery.json => package.json | 16 +++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) rename googlemap.jquery.json => package.json (54%) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index b8995a2..80b6379 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -6,7 +6,11 @@ $(function() { coords : [48.895651, 2.290569], type : "ROADMAP", debug : false, - langage : "english" + langage : "english", + overviewMapControl: false, + streetViewControl: false, + scrollwheel: false, + mapTypeControl: false }, params); switch(params.type) { @@ -27,10 +31,10 @@ $(function() { zoom: params.zoom, center: new google.maps.LatLng(params.coords[0], params.coords[1]), mapTypeId: params.type, - scrollwheel: false, - streetViewControl: false, - overviewMapControl: false, - mapTypeControl: false + scrollwheel: params.scrollwheel, + streetViewControl: params.streetViewControl, + overviewMapControl: params.overviewMapControl, + mapTypeControl: params.mapTypeControl }); $(this).data('googleMap', map); diff --git a/googlemap.jquery.json b/package.json similarity index 54% rename from googlemap.jquery.json rename to package.json index ff92592..f0623f8 100644 --- a/googlemap.jquery.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "googlemap", + "name": "jquery-googlemap", "title": "Google Map", - "version": "1.4.3", + "version": "1.5.0", "author": { - "name": "Thibault HENRY", - "email": "thibaulthenry@tilotiti.com", - "url": "http://www.tiloblog.com/" + "name": "Thibault HENRY", + "email": "thibault@henry.pro", + "url": "http://www.tiloweb.com/" }, "licenses": [ { @@ -15,10 +15,8 @@ ], "description": "A jQuery Plugin allows you to easely manipulate the Google Map API. You are now able to create maps, add some markers and create routes.", "homepage": "http://tilotiti.github.com/jQuery-Google-Map/", - "docs": "http://tilotiti.github.com/jQuery-Google-Map/", - "demo": "http://tilotiti.github.com/jQuery-Google-Map/", - "download": "https://github.com/tilotiti/jQuery-Google-Map/archive/master.zip", - "keywords": ["map", "googlemap", "google", "geocode", "route"], + "repository": "https://github.com/Tilotiti/jQuery-Google-Map/", + "keywords": ["map", "googlemap", "google", "geocode", "route", "jquery-plugin", "ecosystem:jquery"], "bugs": "http://tilotiti.github.com/jQuery-Google-Map/", "dependencies": { "jquery": ">=1.7" From 2fc4ef0b3a1b38f50201a9402721c11b657ef463 Mon Sep 17 00:00:00 2001 From: Thibault Henry Date: Tue, 16 Oct 2018 12:41:04 +0200 Subject: [PATCH 11/12] Get Zipcode in the addMarker success function. --- jquery.googlemap.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 5329700..62b2a9d 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -155,6 +155,12 @@ $(function() { var coords = {}; coords.lat = results[0].geometry.location.lat(); coords.lon = results[0].geometry.location.lng(); + + for(var i in results[0].address_components) { + if(results[0].address_components[i].types.indexOf("postal_code") > -1) { + coords.zipcode = results[0].address_components[i].long_name; + } + } params.success(coords, $this); From 75ee9c7db3a514e152704f25fb4561eda0f94997 Mon Sep 17 00:00:00 2001 From: Rohan Khude Date: Tue, 26 Feb 2019 18:00:45 +0530 Subject: [PATCH 12/12] Close infowindow when another marker is clicked --- jquery.googlemap.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jquery.googlemap.js b/jquery.googlemap.js index 62b2a9d..e3b3403 100644 --- a/jquery.googlemap.js +++ b/jquery.googlemap.js @@ -129,9 +129,12 @@ $(function() { }); var map = $that.data('googleMap'); - + previous_infowindow = null; google.maps.event.addListener(marker, 'click', function() { + if(previous_infowindow!==null) + previous_infowindow.close(map, marker); infowindow.open(map, marker); + previous_infowindow=infowindow; }); } else if(params.url) { google.maps.event.addListener(marker, 'click', function() { @@ -196,9 +199,12 @@ $(function() { }); var map = $this.data('googleMap'); - + previous_infowindow = null; google.maps.event.addListener(marker, 'click', function() { + if(previous_infowindow!==null) + previous_infowindow.close(map, marker); infowindow.open(map, marker); + previous_infowindow=infowindow; }); } else if(params.url) { google.maps.event.addListener(marker, 'click', function() {