/** * Adds a polyline or polygon to the google map. * * @param $pPolyline [string] - an array of lat/lon associative arrays * @param $pColor string - the hex code for the color of the polyline * @param $pStroke integer - the thickness, in pixels, of the polyline * @param $pFillColor string - the hex code for the fill color (optional) * * @return string - the javascript string for adding the polyline to the map **/ function addPolyline($pPolyline, $pLineColor, $pLineOpacity, $pStroke, $pFillColor, $pFillOpacity) { // get a hex code and transparency for the color if (count($pPolyline) == 0) { return; } if (!$this->mEnablePaths) { return; } $polyline = array(); foreach ($pPolyline as $p) { $polyline[] = "new GLatLng({$p['lat']}, {$p['lon']})"; } $lineOpacity = GoogleMaps::hex2fraction($pLineOpacity); if (isset($pFillColor)) { $fillOpacity = GoogleMaps::hex2fraction($pFillOpacity); $polyline[] = $polyline[0]; $this->mOutput .= " map.addOverlay(new GPolygon( [ " . implode(", ", $polyline) . " ], " . "'#{$pLineColor}', {$pStroke} , {$lineOpacity}, " . "'#{$pFillColor}', {$fillOpacity}, {'clickable': false})); "; } else { // build the javascript for adding the polyline $this->mOutput .= " map.addOverlay(new GPolyline( [ " . implode(", ", $polyline) . " ], " . "'#{$pLineColor}', {$pStroke}, {$lineOpacity}, {'clickable': false})); "; } }