The path of file stores marker icon info (as json data): sites/default/files/js/gmap_marker.js
(marker icon 的图标地址,在sites/default/files/js/gmap_marker.js文件下。)
In this js file, there are two variables:
1), Drupal.gmap.iconpath the path of marker icon folder ( eg: gmap/marker )
2), Drupal.gmap.icondata it's a json data
eg: { "/small/": { "f": [ "shadow.png", …………
Example:
1), get the value "/small/"
=============================
for(var key in Drupal.gmap.icondata)
{
var file = Drupal.gmap.icondata[key];
// key value: /small
// file value: { "f": [ "shadow.png", …………
}
=============================
(要取出子目录"/small", for(var key in Drupal.gmap.icondata), 这里的key就能取到"/small"
而 Drupal.gmap.icondata[key]的值就是{ "f": [ "shadow.png", …………
以此类推,便能将其中的所有的值一一对应取出。)
The code we use:
(代码如下):
=============================
for (var key1 in Drupal.gmap.icondata) {
for (var key2 in Drupal.gmap.icondata[key1].i) {
for (var key3 in Drupal.gmap.icondata[key1].i[key2]){
for(var key4 in Drupal.gmap.icondata[key1].i[key2][key3][0]){
marker_icons[Drupal.gmap.icondata[key1].i[key2][key3][0][key4]] = key1 + Drupal.gmap.icondata[key1].f[Drupal.gmap.icondata[key1].i[key2][key3][2][key4]];
}
}
}
}
===============================
As what we need is just the path of marker icon ( not include the shadow icon and other parameters), so we just fetch two values.
(因为我们需要的只是marker icon 的文件地址(不包括起阴影和其他icon的参数设置)故只取两个值。)
marker_icons[key] is the path of marker icon
key is the category name we used in module function
Example: school
===============================
for(var key in marker_icons)
{
if(key=="school")
icon_path = Drupal.gmap.iconpath + marker_icon[key];
}
===============================