Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 36 additions & 19 deletions sources/web/js/map-input-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
);
}
);
}

};

Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -301,7 +309,7 @@ function MapInputWidget ( widget )
{
map: map,
position: point,
draggable: true,
draggable: isEditMode(),
animation: markerAnimation,
}
);
Expand Down Expand Up @@ -335,16 +343,25 @@ 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();
};

};

// A global instance of map inputs manager.
// Use it to get references to widget instances.
var mapInputWidgetManager;

$(window).load
(
function()
$(window).on('load', function()
{

// Create an instance of widget manager
Expand Down
2 changes: 1 addition & 1 deletion sources/web/js/map-input-widget.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions sources/widgets/MapInputWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class MapInputWidget extends \yii\widgets\InputWidget

public $enableSearchBar = true;

public $editMode = true;

public function run()
{

Expand All @@ -53,6 +55,7 @@ public function run()
'animateMarker' => $this->animateMarker,
'alignMapCenter' => $this->alignMapCenter,
'enableSearchBar' => $this->enableSearchBar,
'editMode' => $this->editMode
]
);
}
Expand Down
1 change: 1 addition & 0 deletions sources/widgets/views/MapInputWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'animate-marker' => $animateMarker,
'align-map-center' => $alignMapCenter,
'enable-search-bar' => $enableSearchBar,
'edit-mode' => $editMode
],
]
);
Expand Down