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
2d2eb237
Commit
2d2eb237
authored
19 years ago
by
webgeer
Browse files
Options
Downloads
Patches
Plain Diff
includes parsing rss feeds
parent
090be745
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
gmap.js
+57
-0
57 additions, 0 deletions
gmap.js
gmap.module
+29
-2
29 additions, 2 deletions
gmap.module
with
86 additions
and
2 deletions
gmap.js
+
57
−
0
View file @
2d2eb237
...
...
@@ -43,3 +43,60 @@ function gmap_textchange(thismap) {
thismap
.
panTo
(
newpoint
=
new
GLatLng
(
$
(
"
gmap-latitude
"
).
value
,
$
(
"
gmap-longitude
"
).
value
));
thismap
.
addOverlay
(
thispoint
=
new
GMarker
(
newpoint
));
}
function
createMarkerFromRSS
(
item
,
icon
)
{
var
title
=
item
.
getElementsByTagName
(
"
title
"
)[
0
].
childNodes
[
0
].
nodeValue
;
// var description = item.getElementsByTagName("description")[0].childNodes[0].nodeValue;
var
link
=
item
.
getElementsByTagName
(
"
link
"
)[
0
].
childNodes
[
0
].
nodeValue
;
// alert('Link: ' +link);
// namespaces are handled by spec in moz, not in ie -- Looking for a better more universal parsing routine.
if
(
navigator
.
userAgent
.
toLowerCase
().
indexOf
(
"
msie
"
)
<
0
)
{
// Is there a geo:lat defined?
if
(
item
.
getElementsByTagNameNS
(
"
http://www.w3.org/2003/01/geo/wgs84_pos#
"
,
"
lat
"
).
length
>
0
)
{
item
.
getElementsByTagNameNS
(
"
http://www.w3.org/2003/01/geo/wgs84_pos#
"
,
"
lat
"
)[
0
].
normalize
();
// Is there a value for geo:lat
if
(
item
.
getElementsByTagNameNS
(
"
http://www.w3.org/2003/01/geo/wgs84_pos#
"
,
"
lat
"
)[
0
].
hasChildNodes
())
{
// Then there probably is a geo:long too
var
lat
=
item
.
getElementsByTagNameNS
(
"
http://www.w3.org/2003/01/geo/wgs84_pos#
"
,
"
lat
"
)[
0
].
childNodes
[
0
].
nodeValue
;
var
lng
=
item
.
getElementsByTagNameNS
(
"
http://www.w3.org/2003/01/geo/wgs84_pos#
"
,
"
long
"
)[
0
].
childNodes
[
0
].
nodeValue
;
}
}
}
else
{
var
lat
=
item
.
getElementsByTagName
(
"
geo:lat
"
)[
0
].
childNodes
[
0
].
nodeValue
;
if
(
lat
==
undefined
)
{
lat
=
item
.
getElementsByTagName
(
"
icbm:lat
"
)[
0
].
childNodes
[
0
].
nodeValue
;
}
var
lng
=
item
.
getElementsByTagName
(
"
geo:long
"
)[
0
].
childNodes
[
0
].
nodeValue
;
if
(
lng
==
undefined
)
{
lng
=
item
.
getElementsByTagName
(
"
icbm:long
"
)[
0
].
childNodes
[
0
].
nodeValue
;
}
}
//alert('Lat: '+lat);
var
point
=
new
GLatLng
(
parseFloat
(
lat
),
parseFloat
(
lng
));
var
html
=
"
<a href=
\"
"
+
link
+
"
\"
>
"
+
title
+
"
</a>
"
;
var
marker
=
createGMarker
(
point
,
html
,
icon
);
return
marker
;
}
function
parseGeoRSS
(
map
,
rssurl
,
icon
)
{
var
request
=
GXmlHttp
.
create
();
request
.
open
(
"
GET
"
,
rssurl
,
true
);
request
.
onreadystatechange
=
function
()
{
if
(
request
.
readyState
==
4
)
{
var
xmlDoc
=
request
.
responseXML
;
var
items
=
xmlDoc
.
documentElement
.
getElementsByTagName
(
"
item
"
);
for
(
var
i
=
0
;
i
<
items
.
length
;
i
++
)
{
var
marker
=
createMarkerFromRSS
(
items
[
i
],
icon
);
map
.
addOverlay
(
marker
);
}
}
}
request
.
send
(
null
);
}
This diff is collapsed.
Click to expand it.
gmap.module
+
29
−
2
View file @
2d2eb237
...
...
@@ -59,6 +59,7 @@ function gmap_perm() {
* shapes - an array of associative arrays for the overlays.
* track - a file containing a series of points in .plt format to be
* inserted into the node.
* feeds - an associative array of rss feeds
*
* Xmaps must be enabled for circle and polygon to work.
*
...
...
@@ -73,6 +74,8 @@ function gmap_perm() {
function
gmap_draw_map
(
$gmap
,
$javascript
=
''
)
{
global
$base_url
;
_gmap_doheader
();
$clusterset
=
false
;
(
!
isset
(
$gmap
[
'width'
]))
?
$gmap
[
'width'
]
=
GMAP_WIDTH
:
NULL
;
(
!
isset
(
$gmap
[
'height'
]))
?
$gmap
[
'height'
]
=
GMAP_HEIGHT
:
NULL
;
(
!
isset
(
$gmap
[
'zoom'
]))
?
$gmap
[
'zoom'
]
=
GMAP_ZOOM
:
NULL
;
...
...
@@ -175,6 +178,7 @@ function gmap_draw_map($gmap, $javascript='') {
if
(
isset
(
$gmap
[
'markers'
]))
{
if
(
GMAP_CLUSTER
)
{
$outtext
.
=
"
\n
var clusterer = new Clusterer("
.
$gmap
[
'id'
]
.
");
\n
"
;
$clusterset
=
true
;
}
$lastmarker
=
''
;
foreach
(
$gmap
[
'markers'
]
as
$item
)
{
...
...
@@ -200,6 +204,7 @@ function gmap_draw_map($gmap, $javascript='') {
}
if
(
GMAP_CLUSTER
)
{
$outtext
.
=
'clusterer.AddMarker(createGMarker(new GLatLng('
.
$item
[
'point'
]
.
'),\''
.
$mytext
.
'\',\''
.
$mymarker
.
"'));
\n
"
;
$clusterset
=
true
;
}
else
{
$outtext
.
=
$gmap
[
'id'
]
.
'.addOverlay(createGMarker(new GLatLng('
.
$item
[
'point'
]
.
'),\''
.
$mytext
.
'\',\''
.
$mymarker
.
"'));
\n
"
;
...
...
@@ -298,6 +303,22 @@ function gmap_draw_map($gmap, $javascript='') {
}
}
}
if
(
isset
(
$gmap
[
'feeds'
]))
{
// if (GMAP_CLUSTER && !$clusterset) {
// $outtext .="\n var clusterer = new Clusterer(".$gmap['id'].");\n";
// }
foreach
(
$gmap
[
'feeds'
]
as
$item
)
{
$mymarker
=
''
;
if
(
isset
(
$item
[
'markername'
])){
if
(
file_exists
(
variable_get
(
'gmap_markerfiles'
,
'modules/gmap/markers'
)
.
'/'
.
$item
[
'markername'
]
.
'.png'
))
{
$mymarker
=
$base_url
.
'/'
.
variable_get
(
'gmap_markerfiles'
,
'modules/gmap/markers'
)
.
'/'
.
$item
[
'markername'
]
.
'.png'
;
}
}
if
(
isset
(
$item
[
'url'
]))
{
$outtext
.
=
"parseGeoRSS("
.
$gmap
[
'id'
]
.
",'"
.
$item
[
'url'
]
.
"','
$mymarker
');
\n
"
;
}
}
}
if
(
strlen
(
$javascript
)
>
0
)
{
$javascript
=
str_replace
(
'{id}'
,
$gmap
[
'id'
],
$javascript
);
$outtext
.
=
$javascript
;
...
...
@@ -417,6 +438,12 @@ function gmap_parse_macro($instring,$ver=2) {
$tt
[
'filename'
]
=
$t
[
1
];
$gmap
[
'track'
][]
=
$tt
;
break
;
case
'feed'
:
$tt
[
'url'
]
=
$t
[
1
];
$gmap
[
'feeds'
][]
=
$tt
;
break
;
case
'line1'
:
$tt
[
'color'
]
=
GMAP_LINECOLOR1
;
...
...
@@ -652,7 +679,7 @@ function gmap_menu($may_cache) {
if
(
variable_get
(
'gmap_user'
,
0
))
{
$items
[]
=
array
(
'path'
=>
'map/users'
,
'type'
=>
MENU_NORMAL_ITEM
,
'title'
=>
t
(
'
U
ser locations'
),
'title'
=>
t
(
'
u
ser locations'
),
'access'
=>
user_access
(
'show user map'
),
'callback'
=>
'gmap_users_page'
);
}
...
...
@@ -873,7 +900,7 @@ function gmap_macro_form() {
'#default_value'
=>
GMAP_CONTROL
,
'#attributes'
=>
array
(
'onchange'
=>
'set_control_type(this.value);'
)
);
$form
[
'macroform'
][
'long
lat
'
]
=
array
(
$form
[
'macroform'
][
'l
atl
ong'
]
=
array
(
'#type'
=>
'textfield'
,
'#id'
=>
'gmap-latlong'
,
'#title'
=>
t
(
'The Latitude and Longitude of the centre of the map'
),
...
...
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