|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
wolfgang Smarty n00b
Joined: 23 May 2008 Posts: 1
|
Posted: Fri May 23, 2008 3:38 pm Post subject: GoogleMapAPI: Draggable Markers and MouseWheel Zoom |
|
|
To zoom by MouseWheel just add the following line to function getMapJS()
Code: |
$_output .= 'map.enableScrollWheelZoom();'."\n";
|
If you like draggable markers:
Code: |
var $draggable = false;
// Make Marker draggable and output coords to "coords_lat" and "coords_lon"
function enableDraggable() {
$this->draggable = true;
}
// disable draggable Markers
function disableDraggable() {
$this->draggable = false;
}
|
Change following in getCreateMarkerJS:
Code: |
if(!empty($this->_icons)) {
if($this->draggable) {
$_output .= 'var marker = new GMarker(point,{\'icon\': icon[n], \'draggable\': true, \'title\': tooltip});' . "\n";
} else {
$_output .= 'var marker = new GMarker(point,{\'icon\': icon[n], \'title\': tooltip});' . "\n";
}
} else {
if($this->draggable) {
$_output .= 'var marker = new GMarker(point,{\'draggable\': true, \'title\': tooltip});' . "\n";
} else {
$_output .= 'var marker = new GMarker(point,{\'title\': tooltip});' . "\n";
}
}
|
Add the following at the end of this function, before "return marker;":
Code: |
if($this->draggable) {
$_output .= 'marker.enableDragging();'."\n";
$_output .= 'GEvent.addListener(marker, "drag", function(){ ';
$_output .= 'document.getElementById("coords_lat").value=marker.getPoint().lat();';
$_output .= 'document.getElementById("coords_lon").value=marker.getPoint().lng();';
$_output .= '});'."\n";
}
|
This could be implemented smarter I think, maybe the author could do it, who has done a great job btw.
Comments and tips welcome, have a look in action at www.bandliste.de |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|