summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2021-10-19 20:24:11 -0300
committerYaco <franco@reevo.org>2021-10-19 20:24:11 -0300
commite3880a1c86acaa3bbd05786ad2f5c586e6511a58 (patch)
treeec77bfc5b69f259a159c95188797bd0dade92357 /www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js
parent20ca0685509f8010580d3b45036a64ab48616af1 (diff)
updates Maps to 7.13.0
Diffstat (limited to 'www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js')
-rw-r--r--www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js b/www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js
new file mode 100644
index 00000000..aa86319e
--- /dev/null
+++ b/www/wiki/extensions/Maps/resources/GoogleMaps/googlemaps3ajax.js
@@ -0,0 +1,48 @@
+/**
+ * JavaScript for Google Maps v3 maps in the Semantic Maps extension.
+ * @see https://www.mediawiki.org/wiki/Extension:Semantic_Maps
+ *
+ * @licence GNU GPL v2+
+ * @author Peter Grassberger < petertheone@gmail.com >
+ */
+
+
+(function( $, sm ) {
+ var ajaxRequest = null;
+ var mapEvents = ['dragend', 'zoom_changed'];
+
+ $( document ).ready( function() {
+ // todo: find a way to remove setTimeout.
+ setTimeout( function() {
+ if( typeof google === 'undefined' ) {
+ return;
+ }
+ $( window.mapsGoogleList ).each( function( index, map ) {
+ if( !map.options.ajaxquery || !map.options.ajaxcoordproperty ) {
+ return;
+ }
+ $( mapEvents ).each( function( index, event ) {
+ google.maps.event.addListener( map.map, event, function() {
+ var bounds = map.map.getBounds();
+ var query = sm.buildQueryString(
+ decodeURIComponent( map.options.ajaxquery.replace( /\+/g, ' ' ) ),
+ map.options.ajaxcoordproperty,
+ bounds.getNorthEast().lat(),
+ bounds.getNorthEast().lng(),
+ bounds.getSouthWest().lat(),
+ bounds.getSouthWest().lng()
+ );
+
+ if( ajaxRequest !== null ) {
+ ajaxRequest.abort();
+ }
+ ajaxRequest = sm.ajaxUpdateMarker( map, query, map.options.icon ).done( function() {
+ map.createMarkerCluster();
+ ajaxRequest = null;
+ } );
+ } );
+ } );
+ } );
+ }, 500 );
+ } );
+})( window.jQuery, window.sm );