Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
geofield_map
Commits
a42d5f3d
Commit
a42d5f3d
authored
Jul 16, 2018
by
itamair
Browse files
Fixed Places Google Maps library with Leaflet Map Widget
parent
2742960e
Changes
1
Hide whitespace changes
Inline
Side-by-side
js/geofield_map.js
View file @
a42d5f3d
...
...
@@ -211,6 +211,33 @@
return
latLng
;
},
// Returns the Map Bounds, in the specific Map Library format.
getMapBounds
:
function
(
mapid
,
map_library
)
{
var
self
=
this
;
var
mapid_map_library
=
self
.
map_data
[
mapid
].
map_library
;
var
ne
,
sw
,
bounds
,
bounds_array
,
bounds_obj
;
if
(
!
map_library
)
{
map_library
=
mapid_map_library
;
}
// Define the bounds object.
// Note: At the moment both Google Maps and Leaflet libraries use the same method names.
bounds
=
self
.
map_data
[
mapid
].
map
.
getBounds
();
if
(
typeof
bounds
===
'
object
'
)
{
ne
=
bounds
.
getNorthEast
();
sw
=
bounds
.
getSouthWest
();
bounds_array
=
[
sw
,
ne
];
switch
(
map_library
)
{
case
'
leaflet
'
:
bounds_obj
=
new
L
.
latLngBounds
(
bounds_array
);
break
;
default
:
bounds_obj
=
new
google
.
maps
.
LatLngBounds
(
bounds_array
);
}
}
return
bounds_obj
;
},
// Define the Geofield Map.
getGeofieldMap
:
function
(
mapid
)
{
var
self
=
this
;
...
...
@@ -446,7 +473,10 @@
self
.
map_data
[
params
.
mapid
].
autocompletePlacesService
=
new
google
.
maps
.
places
.
Autocomplete
(
self
.
map_data
[
params
.
mapid
].
search
.
get
(
0
),
self
.
map_data
[
params
.
mapid
].
gmap_places_options
);
self
.
map_data
[
params
.
mapid
].
autocompletePlacesService
.
bindTo
(
'
bounds
'
,
self
.
map_data
[
params
.
mapid
].
map
);
// Set the bias to the Google Maps Bounds, if the Google Maps exists, as the map library.
if
(
self
.
getMapBounds
(
params
.
mapid
)
===
'
object
'
)
{
self
.
map_data
[
params
.
mapid
].
autocompletePlacesService
.
bindTo
(
'
bounds
'
,
self
.
getMapBounds
(
params
.
mapid
));
}
self
.
map_data
[
params
.
mapid
].
autocompletePlacesService
.
addListener
(
'
place_changed
'
,
function
()
{
self
.
map_data
[
params
.
mapid
].
search
.
removeClass
(
'
ui-autocomplete-loading
'
);
var
place
=
self
.
map_data
[
params
.
mapid
].
autocompletePlacesService
.
getPlace
();
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment