0

我正在研究谷歌地图,我试图按颜色对我的标记进行分类。类别表有[id,categoryname,color],标记表有[id,....,category(类别表类别的id)]。

在 PHP 中:

 $result = mysql_query("SELECT * FROM `markers`");

    //Multiple rows are returned
    while ($row = mysql_fetch_array($result, MYSQL_NUM))
    {

        if ( $x == 0 )
        {
             $separator = "";
        }
        else
        {
             $separator = "****";
        }
        //Saving to the String, each variable is separated by three &'s
        $encodedString = $encodedString.$separator.
            "<b><div class='name'></b>".$row[3].
        "</div><div class='opli'><b>Lon:</b> ".$row[2].
        "</div><div class='opli'><b>Lat:</b>".$row[1].
        "</div><div class='opli'><b>Address:</b>".$row[4].
        "</div><div class='opli'><b>Category:</b>".$row[5].
        "</div></div>&&&".$row[1]."&&&".$row[2]."&&&".$row[6]."&&&".$row[5];

        $x = $x + 1;
   $colorgetterq= mysql_query("SELECT color FROM `map`.`category` WHERE id= ".$row[5]."");
   $colorgettert = mysql_fetch_row($colorgetterq);
   $colorgetter= $colorgettert[0];
      } 

在 Java 中:colorget = document.getElementById("colorget").value;

    stringArray = encodedString.split("****");

    var x;
    for (x = 0; x < stringArray.length; x = x + 1)
    {
        var addressDetails = [];
        var scale1 = [];
        var marker;
        //Separate each field
        addressDetails = stringArray[x].split("&&&");
        //Load the lat, long data
        var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
        //Create a new marker and info window


        marker = new google.maps.Marker({
            map: map,
            position: lat,
            icon: {                
            strokeWeight: 0.01,
            fillColor: colorget,
            fillOpacity: 0.85,
             path: google.maps.SymbolPath.CIRCLE,
             scale:  5 + addressDetails[3] * (35-5)/(hiscale-loscale),
            },
            content: addressDetails[0]
        });

我不知道我在做什么是错的,但在填充颜色中,由于某种原因颜色仍然是黑色,并且不会加载不同的类别颜色。

4

1 回答 1

0

这里有很多问题,但让这对你有用。

将此行替换$colorgetter= $colorgettert[0];$encodedString= $encodedString."&&&" . $colorgettert[0];

而这条fillColor: colorget,线fillColor: addressDetails[6],

于 2013-08-19T16:00:55.377 回答