diff --git a/README.md b/README.md index 65921469d..3cfd57f1c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Cordova GoogleMaps plugin for Android, iOS and Browser (version 2.4.0) +# Cordova GoogleMaps plugin for Android, iOS and Browser (version 2.4.1) This plugin displays Google Maps in your application. This plugin uses these libraries for each platforms: @@ -51,7 +51,7 @@ ```xml - + @@ -154,7 +154,7 @@ ### Which browser supported? Modern browsers should work without any problem. - ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/modern_browser.png) + ![](https://raw.githubusercontent.com/mapsplugin/cordova-plugin-googlemaps/master/images/modern_browsers.png) Internet Explorer 11 might work. We don't confirm all features, but basic features work. @@ -192,6 +192,10 @@ --------------------------------------------------------------------------------------------------------- ## Release Notes + - **v2.4.1** + - Fix: `map.getMap()` does not work when page changing on ionic v4. + - Fix: `LocationService.hasPermission()` is not implement for browser platform. + - **v2.4.0** - Add: `Browser` platform! - Add: `plugin.google.maps.environment.setEnv()` method. @@ -207,7 +211,6 @@ ![](https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/raw/master/v1.4.0/top/demo.gif) -[Demo (Browser)](https://mapsplugin.github.io/HelloGoogleMap/) --------------------------------------------------------------------------------------------------------- diff --git a/images/modern_browsers.png b/images/modern_browsers.png index d414f2024..cca0f7bd1 100644 Binary files a/images/modern_browsers.png and b/images/modern_browsers.png differ diff --git a/package.json b/package.json index 0aedc960e..176b2e9ff 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cordova-plugin-googlemaps", - "version": "2.4.0", - "description": "Google Maps native SDK for Android and iOS", + "version": "2.4.1", + "description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.", "cordova": { "id": "cordova-plugin-googlemaps", "platforms": [ diff --git a/plugin.xml b/plugin.xml index 41e179c8d..b56adad18 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - + cordova-plugin-googlemaps diff --git a/src/browser/CordovaGoogleMaps.js b/src/browser/CordovaGoogleMaps.js index 90013a87d..a2eb6354a 100644 --- a/src/browser/CordovaGoogleMaps.js +++ b/src/browser/CordovaGoogleMaps.js @@ -115,6 +115,7 @@ var CordovaGoogleMaps = { pluginMap = null; MAPS[mapId] = undefined; delete MAPS[mapId]; + onSuccess(); }, getPanorama: function(onSuccess, onError, args) { diff --git a/src/browser/PluginLocationService.js b/src/browser/PluginLocationService.js index 9cb5ca9b1..d5c33f8df 100644 --- a/src/browser/PluginLocationService.js +++ b/src/browser/PluginLocationService.js @@ -11,6 +11,17 @@ var LOCATION_ERROR = { }; module.exports = { + 'hasPermission': function(onSuccess, onError, args) { + if (navigator.permissions) { + navigator.permissions.query({'name': 'geolocation'}) + .then(function(permission) { + onSuccess(permission.state === 'granted' ? 1 : 0); + }) + .catch(onError); + } else { + onError('Browser does not support this feature.'); + } + }, 'getMyLocation': function(onSuccess, onError, args) { if (navigator.geolocation) { diff --git a/www/js_CordovaGoogleMaps-for-browser.js b/www/js_CordovaGoogleMaps-for-browser.js index 3b0e47e0b..6830639b8 100644 --- a/www/js_CordovaGoogleMaps-for-browser.js +++ b/www/js_CordovaGoogleMaps-for-browser.js @@ -26,6 +26,46 @@ function CordovaGoogleMaps(execCmd) { self.MAPS = {}; self.MAP_CNT = 0; + var removeMapDiv = function(node) { + if (node.hasAttribute('__pluginmapid') && !node.parentNode) { + var mapId = node.getAttribute('__pluginmapid'); + var map = self.MAPS[mapId]; + if (map) { + map.remove(); + delete self.MAPS[mapId]; + } + } else { + var childNodes = Array.prototype.slice.call(node.childNodes); + childNodes.forEach(function(child) { + if (child.outerHTML && child.outerHTML.indexOf('__pluginmapid') > -1) { + removeMapDiv(child); + } + }); + } + }; + + //------------------------------------------------------------------------------ + // Using MutationObserver, observe only added/removed or style changed elements + //------------------------------------------------------------------------------ + var observer = new MutationObserver(function(mutations) { + common.nextTick(function() { + var mutationRecords = Array.prototype.slice.call(mutations, 0); + mutationRecords.forEach(function(record) { + if (record.removedNodes.length > 0) { + record.removeNodes = Array.prototype.slice.call(record.removedNodes, 0); + record.removeNodes.forEach(function(node) { + if (node.outerHTML && node.outerHTML.indexOf('__pluginmapid') > -1) { + removeMapDiv(node); + } + }); + } + }); + }); + }); + observer.observe(document.body.parentElement, { + childList: true, + subtree: true + }); } CordovaGoogleMaps.prototype.getMap = function(div, mapOptions) {