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
f6bcb90a
Commit
f6bcb90a
authored
11 years ago
by
jaxxed
Committed by
Andriy Podanenko http://druler.com
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1982320 by jaxxed: Gmaps shapes library upgrade to v3 compatible format.
parent
1f7e3cec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/gmap_shapes.js
+22
-14
22 additions, 14 deletions
js/gmap_shapes.js
with
22 additions
and
14 deletions
js/gmap_shapes.js
+
22
−
14
View file @
f6bcb90a
...
@@ -14,42 +14,48 @@
...
@@ -14,42 +14,48 @@
*/
*/
/*global $, Drupal, google.maps, !google.maps.geometry! */
/*global $, Drupal, google.maps, !google.maps.geometry! */
(
function
(
$
)
{
Drupal
.
gmap
.
addHandler
(
'
gmap
'
,
function
(
elem
)
{
Drupal
.
gmap
.
addHandler
(
'
gmap
'
,
function
(
elem
)
{
var
obj
=
this
;
var
obj
=
this
;
// prepare and build a google.maps shape object
// prepare and build a google.maps shape object
obj
.
bind
(
'
prepareshape
'
,
function
(
shape
)
{
obj
.
bind
(
'
prepareshape
'
,
function
(
shape
)
{
var
pa
,
cargs
,
style
fill
style
;
var
style
;
fillstyle
=
false
;
// does this shape have a fill option?
var
fillstyle
=
false
;
// does this shape have a fill option?
cargs
=
{};
var
cargs
=
{};
pa
=
[];
// point array (array of LatLng-objects)
var
pa
=
[];
// point array (array of LatLng-objects)
// positioning determination
// positioning determination
switch
(
shape
.
type
)
{
switch
(
shape
.
type
)
{
case
'
circle
'
:
case
'
circle
'
:
if
(
typeof
shape
.
center
===
'
array
'
)
{
shape
.
center
=
new
google
.
maps
.
LatLng
(
shape
.
center
[
0
],
shape
.
center
[
1
]);
}
// otherwise it should be a LatLng already
if
(
shape
.
center
.
length
)
{
shape
.
center
=
new
google
.
maps
.
LatLng
(
shape
.
center
[
0
],
shape
.
center
[
1
]);
}
// otherwise it should be a LatLng already
if
(
shape
.
point2
)
{
if
(
shape
.
opts
.
radius
)
{
if
(
typeof
shape
.
point2
===
'
array
'
)
{
shape
.
point2
=
new
google
.
maps
.
LatLng
(
shape
.
point2
[
0
],
shape
.
point2
[
1
]);
}
// otherwise it should be a LatLng already
shape
.
radius
=
shape
.
opts
.
radius
;
}
else
if
(
shape
.
point2
)
{
if
(
shape
.
point2
.
length
)
{
shape
.
point2
=
new
google
.
maps
.
LatLng
(
shape
.
point2
[
0
],
shape
.
point2
[
1
]);
}
// otherwise it should be a LatLng already
shape
.
radius
=
(
google
.
maps
.
geometry
)
?
google
.
maps
.
geometry
.
spherical
.
computeDistanceBetween
(
shape
.
center
,
shape
.
point2
)
:
250
;
shape
.
radius
=
(
google
.
maps
.
geometry
)
?
google
.
maps
.
geometry
.
spherical
.
computeDistanceBetween
(
shape
.
center
,
shape
.
point2
)
:
250
;
}
// if you didn't pass a shape.point2, then you should have passed a shape.radius in meters
}
// if you didn't pass a shape.point2, then you should have passed a shape.radius in meters
break
;
break
;
case
'
rpolygon
'
:
/* this is deprecated as we have circle now. It is left for backwards compatibility */
case
'
rpolygon
'
:
/* this is deprecated as we have circle now. It is left for backwards compatibility */
if
(
typeof
shape
.
center
===
'
array
'
)
{
shape
.
center
=
new
google
.
maps
.
LatLng
(
shape
.
center
[
0
],
shape
.
center
[
1
]);
}
// otherwise it should be a LatLng already
if
(
shape
.
center
.
length
)
{
shape
.
center
=
new
google
.
maps
.
LatLng
(
shape
.
center
[
0
],
shape
.
center
[
1
]);
}
// otherwise it should be a LatLng already
if
(
typeof
shape
.
point2
===
'
array
'
)
{
shape
.
point2
=
new
google
.
maps
.
LatLng
(
shape
.
point2
[
0
],
shape
.
point2
[
1
]);
}
// otherwise it should be a LatLng already
if
(
shape
.
point2
.
length
)
{
shape
.
point2
=
new
google
.
maps
.
LatLng
(
shape
.
point2
[
0
],
shape
.
point2
[
1
]);
}
// otherwise it should be a LatLng already
shape
.
radius
=
(
google
.
maps
.
geometry
)
?
google
.
maps
.
geometry
.
spherical
.
computeDistanceBetween
(
shape
.
center
,
shape
.
point2
)
:
250
;
shape
.
radius
=
(
google
.
maps
.
geometry
)
?
google
.
maps
.
geometry
.
spherical
.
computeDistanceBetween
(
shape
.
center
,
shape
.
point2
)
:
250
;
if
(
!
shape
.
numpoints
)
{
shape
.
numpoints
=
20
;
}
if
(
!
shape
.
numpoints
)
{
shape
.
numpoints
=
20
;
}
pa
=
obj
.
poly
.
calcPolyPoints
(
shape
.
center
,
radius
,
shape
.
numpoints
);
pa
=
obj
.
poly
.
calcPolyPoints
(
shape
.
center
,
shape
.
radius
,
shape
.
numpoints
);
break
;
break
;
case
'
polygon
'
:
case
'
polygon
'
:
fillstyle
=
true
;
fillstyle
=
true
;
case
'
line
'
:
case
'
line
'
:
$
.
each
(
shape
.
points
,
function
(
i
,
n
)
{
if
(
shape
.
points
)
{
if
(
typeof
n
===
'
array
'
)
{
n
=
new
google
.
maps
.
LatLng
(
n
[
0
],
n
[
1
]);
}
// otherwise it should be a LatLng already
$
.
each
(
shape
.
points
,
function
(
i
,
n
)
{
pa
.
push
(
n
);
if
(
n
.
length
)
{
n
=
new
google
.
maps
.
LatLng
(
n
[
0
],
n
[
1
]);
}
// otherwise it should be a LatLng already
});
pa
.
push
(
n
);
});
}
break
;
break
;
case
'
encoded_polygon
'
:
case
'
encoded_polygon
'
:
...
@@ -194,3 +200,5 @@ Drupal.gmap.addHandler('gmap', function (elem) {
...
@@ -194,3 +200,5 @@ Drupal.gmap.addHandler('gmap', function (elem) {
}
}
});
});
});
});
})(
jQuery
);
\ No newline at end of file
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