コードのコメントを参照してください:あなたはlocpickchange_click
& locpickchange_dragend
を使用したい場合には
if (GBrowserIsCompatible())
{
Drupal.gmap.addHandler('gmap', function(elem, context) {
var gmap = this;
// Note: GMap module does not support solely
// "locpickchange_dragend" and "locpickchange_click" events
// by default. It combines map clicks, marker drag and
// dragend events in an custom event called "locpickchange".
// Binding on those said solely triggers relies on a GMap
// locpick widget patch which is included.
//
gmap.bind('locpickchange', function(context) {
// Note: The coordinations stored in gmap.vars.latitude and
// gmap.vars.longitude are for the previous location of the
// locpicker marker, we need to use gmap.locpick_coord which
// is pretty live!
//
if (gmap.locpick_coord) {
// TODO: Implement the logic.
// Current latitude: gmap.locpick_coord.lat()
// Curren longitude: gmap.locpick_coord.lng()
}
});
}
、ここで汚れたGMapのモジュールのパッチは次のとおりです。
From 2fb5a1ca71e1470e5413f10fb83ce959cd1d8634 Mon Sep 17 00:00:00 2001
From: Sepehr Lajevardi <[email protected]>
Date: Fri, 8 Jul 2011 14:38:27 +0430
Subject: [PATCH] Extends the locpick widget event system by adding
lockpickchange_click and locpickchange_dragend custom
events.
---
js/locpick.js | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/js/locpick.js b/js/locpick.js
index d5aae9c..7c207f9 100644
--- a/js/locpick.js
+++ b/js/locpick.js
@@ -16,6 +16,18 @@ Drupal.gmap.addHandler('gmap', function (elem) {
}
});
+ // Bind triggering of a map click on our custom events.
+ obj.bind("locpickchange_dragend", function() {
+ if (obj.locpick_coord) {
+ GEvent.trigger(obj.map, "click", null, obj.locpick_coord);
+ }
+ });
+ obj.bind("locpickchange_click", function() {
+ if (obj.locpick_coord) {
+ GEvent.trigger(obj.map, "click", null, obj.locpick_coord);
+ }
+ });
+
obj.bind("locpickremove", function() {
obj.map.removeOverlay(obj.locpick_point);
obj.locpick_coord = null;
@@ -40,10 +52,16 @@ Drupal.gmap.addHandler('gmap', function (elem) {
GEvent.addListener(obj.locpick_point, 'dragend', function() {
obj.locpick_coord = obj.locpick_point.getLatLng();
obj.change('locpickchange', binding);
+ // Also trigger a locpickchange_dragend event
+ // so we can bind on just marker dragends.
+ obj.change('locpickchange_dragend', binding);
});
obj.locpick_coord = point;
obj.map.panTo(point);
obj.change('locpickchange', binding);
+ // Also trigger a locpickchange_click event
+ // so we can bind on just map clicks.
+ obj.change('locpickchange_click', binding);
}
else {
// Unsetting the location
--
1.7.6