Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gmap
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
gmap
Commits
43a9db6d
Commit
43a9db6d
authored
10 years ago
by
placinta
Committed by
podarok
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2157629 by Placinta: Gmap + Location Additional Address Field, Option to Ignore when Mapping
parent
a8ea2eb3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
location_gmap_find_address/location_gmap_find_address.api.js
+26
-0
26 additions, 0 deletions
location_gmap_find_address/location_gmap_find_address.api.js
location_gmap_find_address/location_gmap_find_address.js
+42
-10
42 additions, 10 deletions
location_gmap_find_address/location_gmap_find_address.js
with
68 additions
and
10 deletions
location_gmap_find_address/location_gmap_find_address.api.js
0 → 100644
+
26
−
0
View file @
43a9db6d
/**
* Documents the JS hooks.
*/
/**
* Allows to alter the address parts of a location address before being geo-coded.
*
* @param object event
* @param object params
* Data to handle:
* - addressParts: An object containing all the address parts
* that are present on the location widget form, which includes:
* name, street, additional, city, province, postal-code, country.
* - separator: The string used to concatenate the address parts.
*/
$
(
document
).
on
(
'
location_gmap_find_address.address_parts_alter
'
,
function
(
event
,
params
)
{
// Remove the name from the address parts object, so it is not
// used in geo-coding process.
if
(
typeof
params
.
addressParts
!==
'
undefined
'
&&
typeof
params
.
addressParts
.
name
!==
'
undefined
'
)
{
delete
params
.
addressParts
.
name
;
}
params
.
separator
=
'
,
'
;
});
This diff is collapsed.
Click to expand it.
location_gmap_find_address/location_gmap_find_address.js
+
42
−
10
View file @
43a9db6d
...
...
@@ -4,19 +4,51 @@
$
(
"
button.location-gmap-find-address-button
"
).
click
(
function
(
e
)
{
e
.
preventDefault
();
var
address_parts
=
[];
var
params
=
{
addressParts
:
{},
separator
:
'
,
'
};
$
(
"
fieldset#
"
+
$
(
this
).
val
()
+
"
.form-item input[type=text],
"
+
"
fieldset#
"
+
$
(
this
).
val
()
+
"
.form-item select > option:selected
"
).
each
(
function
()
{
if
(
!
$
(
this
).
hasClass
(
'
gmap-control
'
)
&&
$
(
this
).
val
()
!==
''
)
{
if
(
$
(
this
).
is
(
'
option
'
))
{
address_parts
.
push
(
$
(
this
).
text
()
);
}
else
{
address_parts
.
push
(
$
(
this
).
val
());
}
"
fieldset#
"
+
$
(
this
).
val
()
+
"
.form-item select > option:selected
"
).
each
(
function
()
{
if
(
!
$
(
this
).
hasClass
(
'
gmap-control
'
)
&&
$
(
this
).
val
()
!==
''
)
{
// Get the html id of the element.
var
isOption
=
$
(
this
).
is
(
'
option
'
);
var
id
;
if
(
isOption
)
{
id
=
$
(
this
).
parent
().
attr
(
'
id
'
);
}
});
else
{
id
=
$
(
this
).
attr
(
'
id
'
);
}
var
id_parts
=
id
.
split
(
'
-
'
);
// The last part of the input id, contains the type
// of the location field. It can be: name, street,
// additional, city, province, postal-code, country.
var
locationFieldType
=
id_parts
[
id_parts
.
length
-
1
];
// Assign the value of the input to the parts
// object.
if
(
isOption
)
{
params
.
addressParts
[
locationFieldType
]
=
$
(
this
).
text
();
}
else
{
params
.
addressParts
[
locationFieldType
]
=
$
(
this
).
val
();
}
}
});
// Trigger location_gmap_find_address.address_parts_alter.
// Allow altering the address parts by custom code.
var
location_field_separator
=
'
,
'
;
$
(
document
).
trigger
(
'
location_gmap_find_address.address_parts_alter
'
,
[
params
]);
var
address_parts_array
=
[];
for
(
var
part
in
params
.
addressParts
)
{
if
(
params
.
addressParts
.
hasOwnProperty
(
part
))
{
address_parts_array
.
push
(
params
.
addressParts
[
part
]);
}
}
var
address_string
=
address_parts
.
join
(
'
,
'
);
var
address_string
=
address_parts
_array
.
join
(
location_field_separator
);
var
gmap_id
=
$
(
"
fieldset#
"
+
$
(
this
).
val
()
+
"
.gmap-map
"
).
attr
(
'
id
'
);
var
geocoder
;
if
(
google
.
maps
.
version
!==
'
undefined
'
)
{
// assume Google Maps API v3 as API v2 did not have this variable
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment