src/GoogleMapAPI.php
function addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$id=false,$color='',$weight=0,$opacity=0) {
		if($id !== false && isset($this->_polylines[$id]) && is_array($this->_polylines[$id])){
			$_polyline = $this->_polylines[$id];
		}else{
			//only set color,weight,and opacity if new polyline
			$_polyline = array(
				"color"=>$color,
				"weight"=>$weight,
				"opacity"=>$opacity
			);
		}
		if(!isset($_polyline['coords']) || !is_array($_polyline['coords'])){
			$_polyline['coords'] = array(
				"0"=> array("lat"=>$lat1, "long"=>$lon1),
				"1"=> array("lat"=>$lat2, "long"=>$lon2)
			);
		}else{
			$last_index = sizeof($_polyline['coords'])-1;
			//check if lat1/lon1 point is already on polyline
			if($_polyline['coords'][$last_index]["lat"] != $lat1 || $_polyline['coords'][$last_index]["long"]  != $lon1){
				$_polyline['coords'][] = array("lat"=>$lat1, "long"=>$lon1);
			}
			$_polyline['coords'][] = array("lat"=>$lat2, "long"=>$lon2);
		}
        if($id === false){
            $this->_polylines[] = $_polyline;
            $id = count($this->_polylines) - 1;
        }else{
			$this->_polylines[$id] = $_polyline;
        }
        $this->adjustCenterCoords($lon1,$lat1);
        $this->adjustCenterCoords($lon2,$lat2);
        // return index of polyline
        return $id;
    }
function addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$id=false,$color='',$weight=0,$opacity=0) {
		if($id !== false && isset($this->_polylines[$id]) && is_array($this->_polylines[$id])){
			$_polyline = $this->_polylines[$id];
		}else{
			//only set color,weight,and opacity if new polyline
			$_polyline = array(
				"color"=>$color,
				"weight"=>$weight,
				"opacity"=>$opacity
			);
		}
		if(!isset($_polyline['coords']) || !is_array($_polyline['coords'])){
			$_polyline['coords'] = array(
				"0"=> array("lat"=>$lat1, "long"=>$lon1),
				"1"=> array("lat"=>$lat2, "long"=>$lon2)
			);
		}else{
			$last_index = sizeof($_polyline['coords'])-1;
			//check if lat1/lon1 point is already on polyline
			if($_polyline['coords'][$last_index]["lat"] != $lat1 || $_polyline['coords'][$last_index]["long"]  != $lon1){
				$_polyline['coords'][] = array("lat"=>$lat1, "long"=>$lon1);
			}
			$_polyline['coords'][] = array("lat"=>$lat2, "long"=>$lon2);
		}
        if($id === false){
            $this->_polylines[] = $_polyline;
            $id = count($this->_polylines) - 1;
        }else{
			$this->_polylines[$id] = $_polyline;
        }
        $this->adjustCenterCoords($lon1,$lat1);
        $this->adjustCenterCoords($lon2,$lat2);
        // return index of polyline
        return $id;
    }
function addPolyLineByCoords ( $ lon1 , $ lat1 , $ lon2 , $ lat2 , $ id = false , $ color = '' , $ weight = 0 , $ opacity = 0 ) { if ( $ id !== false && isset ( $ this -> _polylines [ $ id ] ) && is_array ( $ this -> _polylines [ $ id ] ) ) { $ _polyline = $ this -> _polylines [ $ id ] ; } else { //only set color,weight,and opacity if new polyline $ _polyline = array ( "color" => $ color , "weight" => $ weight , "opacity" => $ opacity ) ; } if ( ! isset ( $ _polyline [ 'coords' ] ) || ! is_array ( $ _polyline [ 'coords' ] ) ) { $ _polyline [ 'coords' ] = array ( "0" => array ( "lat" => $ lat1 , "long" => $ lon1 ) , "1" => array ( "lat" => $ lat2 , "long" => $ lon2 ) ) ; } else { $ last_index = sizeof ( $ _polyline [ 'coords' ] ) - 1 ; //check if lat1/lon1 point is already on polyline if ( $ _polyline [ 'coords' ] [ $ last_index ] [ "lat" ] != $ lat1 || $ _polyline [ 'coords' ] [ $ last_index ] [ "long" ] != $ lon1 ) { $ _polyline [ 'coords' ] [ ] = array ( "lat" => $ lat1 , "long" => $ lon1 ) ; } $ _polyline [ 'coords' ] [ ] = array ( "lat" => $ lat2 , "long" => $ lon2 ) ; } if ( $ id === false ) { $ this -> _polylines [ ] = $ _polyline ; $ id = count ( $ this -> _polylines ) - 1 ; } else { $ this -> _polylines [ $ id ] = $ _polyline ; } $ this -> adjustCenterCoords ( $ lon1 , $ lat1 ) ; $ this -> adjustCenterCoords ( $ lon2 , $ lat2 ) ; // return index of polyline return $ id ; }
adds a map polyline by map coordinates
if color, weight and opacity are not defined, use the google maps defaults

@param string $lon1 the map longitude to draw from
@param string $lat1 the map latitude to draw from
@param string $lon2 the map longitude to draw to
@param string $lat2 the map latitude to draw to
@param string $id An array id to use to append coordinates to a line
@param string $color the color of the line (format: #000000)
@param string $weight the weight of the line in pixels
@param string $opacity the line opacity (percentage)
@return string $id id of the created/updated polyline array
adds a map polyline by map coordinates if color weight and opacity are not defined use the google maps defaults