diff --git a/sources/web/js/map-input-widget.js b/sources/web/js/map-input-widget.js index ee7882f..23b8434 100644 --- a/sources/web/js/map-input-widget.js +++ b/sources/web/js/map-input-widget.js @@ -105,21 +105,23 @@ function MapInputWidget ( widget ) } ); - google.maps.event.addListener - ( - map, - 'click', - function ( click ) - { - self.setPosition - ( - { - latitude: click.latLng.lat(), - longitude: click.latLng.lng(), - } - ); - } - ); + if(isEditMode()){ + google.maps.event.addListener + ( + map, + 'click', + function ( click ) + { + self.setPosition + ( + { + latitude: click.latLng.lat(), + longitude: click.latLng.lng(), + } + ); + } + ); + } }; @@ -245,6 +247,12 @@ function MapInputWidget ( widget ) return point; } + var isEditMode = function () + { + var mode = $(widget).data('edit-mode'); + return mode === 1; + }; + // Initializes widget this.initialize = function() { @@ -301,7 +309,7 @@ function MapInputWidget ( widget ) { map: map, position: point, - draggable: true, + draggable: isEditMode(), animation: markerAnimation, } ); @@ -335,6 +343,17 @@ function MapInputWidget ( widget ) map.setZoom(zoom); }; + // Resize the map + this.resize = function() + { + google.maps.event.trigger(map, "resize"); + }; + + // Gets the initial point + this.getInitialPoint = function () + { + return getInitialValue(); + }; }; @@ -342,9 +361,7 @@ function MapInputWidget ( widget ) // Use it to get references to widget instances. var mapInputWidgetManager; -$(window).load -( - function() +$(window).on('load', function() { // Create an instance of widget manager diff --git a/sources/web/js/map-input-widget.min.js b/sources/web/js/map-input-widget.min.js index 96caec6..87a769e 100644 --- a/sources/web/js/map-input-widget.min.js +++ b/sources/web/js/map-input-widget.min.js @@ -1 +1 @@ -function MapInputWidgetManager(){const b=".kolyunya-map-input-widget";var a=this;var c=Array();var e=function(f){if(!$(f).data("initialized")){var g=new MapInputWidget(f);g.initialize();return g}return null};var d=function(g){var f=g.getId();c[f]=g};this.initializeWidgets=function(){$(b).each(function(f,g){var h=e(g);if(h){d(h)}})};this.getWidget=function(f){var g=c[f];return g}}function MapInputWidget(f){const p="input.kolyunya-map-input-widget-input";const b="input.kolyunya-map-input-widget-search-bar";const c="div.kolyunya-map-input-widget-canvas";var l=this;var j;var m;var d;var s;var r=function(){j=$(f).find(p).get(0);m=$(f).find(b).get(0);d=$(f).find(c).get(0)};var a=function(){s=new google.maps.Map(d,{mapTypeId:$(f).data("map-type"),center:q(),zoom:$(f).data("zoom"),styles:[{featureType:"poi",stylers:[{visibility:"off",},],},],mapTypeControlOptions:{mapTypeIds:[],},});google.maps.event.addListener(s,"click",function(u){l.setPosition({latitude:u.latLng.lat(),longitude:u.latLng.lng(),})})};var h=function(){var u=e();l.setPosition(u);$(f).data("initialized",true)};var t=function(){var u=$(f).data("enable-search-bar");var v=!u;$(m).prop("hidden",v);searchBarAutocomplete=new google.maps.places.Autocomplete(m);s.controls[google.maps.ControlPosition.TOP_LEFT].push(m);google.maps.event.addListener(searchBarAutocomplete,"place_changed",function(){var w=this.getPlace();var x=w.geometry;if(x){var y=x.location;l.setPosition(y)}})};var g=function(v){var w=i();var u=n(v);w=w.replace(/%latitude%/g,u.lat());w=w.replace(/%longitude%/g,u.lng());return w};var k=function(){var u=$(j).prop("value")!="";return u};var e=function(){var D;var z=i();var B=$(j).prop("value");if(B!==""){var x=z.indexOf("%latitude%");var A=z.indexOf("%longitude%");var v=x $this->animateMarker, 'alignMapCenter' => $this->alignMapCenter, 'enableSearchBar' => $this->enableSearchBar, + 'editMode' => $this->editMode ] ); } diff --git a/sources/widgets/views/MapInputWidget.php b/sources/widgets/views/MapInputWidget.php index 8bab973..c9e6c6c 100644 --- a/sources/widgets/views/MapInputWidget.php +++ b/sources/widgets/views/MapInputWidget.php @@ -23,6 +23,7 @@ 'animate-marker' => $animateMarker, 'align-map-center' => $alignMapCenter, 'enable-search-bar' => $enableSearchBar, + 'edit-mode' => $editMode ], ] );